pub trait SubFrom<Lhs = Self> {
// Required method
fn sub_from(&mut self, lhs: Lhs);
}
Expand description
Compound subtraction and assignment to the rhs operand.
rhs.sub_from(lhs)
has the same effect as rhs = lhs - rhs
.
Examples
use rug::ops::SubFrom;
struct I(i32);
impl SubFrom<i32> for I {
fn sub_from(&mut self, lhs: i32) {
self.0 = lhs - self.0;
}
}
let mut i = I(10);
i.sub_from(42);
assert_eq!(i.0, 32);