Trait rug::ops::AddFrom [] [src]

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

Compound addition and assignment to the rhs operand.

rhs.add_from(lhs) has the same effect as rhs = lhs + rhs.

Examples

use rug::ops::AddFrom;
struct S(String);
impl<'a> AddFrom<&'a str> for S {
    fn add_from(&mut self, lhs: &str) {
        self.0.insert_str(0, lhs);
    }
}
let mut s = S("world!".into());
s.add_from("Hello, ");
assert_eq!(s.0, "Hello, world!");

Required Methods

Peforms the addition.

Examples

use rug::Integer;
use rug::ops::AddFrom;
let mut rhs = Integer::from(10);
rhs.add_from(100);
// rhs = 100 + 10
assert_eq!(rhs, 110);

Implementors