Trait rug::ops::SubFrom [] [src]

pub trait SubFrom<Lhs = Self> {
    fn sub_from(&mut self, lhs: Lhs);
}

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);

Required Methods

Peforms the subtraction.

Examples

use rug::Integer;
use rug::ops::SubFrom;
let mut rhs = Integer::from(10);
rhs.sub_from(100);
// rhs = 100 - 10
assert_eq!(rhs, 90);

Implementors