Trait std::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
Implementors
impl SubAssign<usize> for usize
impl SubAssign<u8> for u8
impl SubAssign<u16> for u16
impl SubAssign<u32> for u32
impl SubAssign<u64> for u64
impl SubAssign<isize> for isize
impl SubAssign<i8> for i8
impl SubAssign<i16> for i16
impl SubAssign<i32> for i32
impl SubAssign<i64> for i64
impl SubAssign<f32> for f32
impl SubAssign<f64> for f64