Trait rug::ops::RemFrom [] [src]

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

Compound remainder operation and assignment to the rhs operand.

rhs.rem_from(lhs) has the same effect as rhs = lhs % rhs.

Examples

use rug::ops::RemFrom;
struct I(i32);
impl RemFrom<i32> for I {
    fn rem_from(&mut self, lhs: i32) {
        self.0 = lhs % self.0;
    }
}
let mut i = I(10);
i.rem_from(42);
assert_eq!(i.0, 2);

Required Methods

Peforms the remainder operation.

Examples

use rug::Integer;
use rug::ops::RemFrom;
let mut rhs = Integer::from(2);
rhs.rem_from(17);
// rhs = 17 / 2
assert_eq!(rhs, 1);

Implementors