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!.

use std::ops::SubAssign; struct Foo; impl SubAssign for Foo { fn sub_assign(&mut self, _rhs: Foo) { println!("Subtracting!"); } } #[allow(unused_assignments)] fn main() { let mut foo = Foo; foo -= Foo; }
use std::ops::SubAssign;

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