pub trait SubAssign<Rhs = Self> { // Required method fnsub_assign(&mut self, rhs: Rhs);}Expand description
The subtraction assignment operator-=.
§Examples
This example creates aPoint struct that implements theSubAssigntrait, and then demonstrates sub-assigning to a mutablePoint.
usestd::ops::SubAssign;#[derive(Debug, Copy, Clone, PartialEq)]structPoint { x: i32, y: i32,}implSubAssignforPoint {fnsub_assign(&mutself, other:Self) {*self=Self{ x:self.x - other.x, y:self.y - other.y, }; }}letmutpoint = Point { x:3, y:3};point -= Point { x:2, y:3};assert_eq!(point, Point {x:1, y:0});