Trait core::ops::SubAssign
[−]
[src]
pub trait SubAssign<Rhs = Self> { fn sub_assign(&mut self, Rhs); }
The SubAssign
trait is used to specify the functionality of -=
.
Examples
A trivial implementation of SubAssign
. When Foo -= Foo
happens, it ends up
calling sub_assign
, and therefore, main
prints Subtracting!
.
#![feature(augmented_assignments)] #![feature(op_assign_traits)] use std::ops::SubAssign; #[derive(Copy, Clone)] struct Foo; impl SubAssign for Foo { fn sub_assign(&mut self, _rhs: Foo) { println!("Subtracting!"); } } fn main() { let mut foo = Foo; foo -= Foo; }
Required Methods
fn sub_assign(&mut self, Rhs)
The method for the -=
operator