pub trait AddFrom<Lhs = Self> {
fn add_from(&mut self, lhs: Lhs);
}
Expand description
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 AddFrom<&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!");