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
fn add_from(&mut self, lhs: Lhs)
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
impl AddFrom for i8
impl AddFrom for i16
impl AddFrom for i32
impl AddFrom for i64
impl AddFrom for isize
impl AddFrom for u8
impl AddFrom for u16
impl AddFrom for u32
impl AddFrom for u64
impl AddFrom for usize
impl AddFrom for f32
impl AddFrom for f64
impl<'a> AddFrom<&'a str> for String
impl<'a> AddFrom<&'a str> for Cow<'a, str>
impl<'a> AddFrom<Cow<'a, str>> for Cow<'a, str>
impl AddFrom<Integer> for Integer
impl<'a> AddFrom<&'a Integer> for Integer
impl AddFrom<i32> for Integer
impl AddFrom<u32> for Integer
impl<'a> AddFrom<MulRef<'a>> for Integer
impl<'a> AddFrom<MulRefU32<'a>> for Integer
impl<'a> AddFrom<MulRefI32<'a>> for Integer
impl AddFrom<Rational> for Rational
impl<'a> AddFrom<&'a Rational> for Rational
impl AddFrom<Float> for Float
impl<'a> AddFrom<&'a Float> for Float
impl AddFrom<Integer> for Float
impl<'a> AddFrom<&'a Integer> for Float
impl AddFrom<Rational> for Float
impl<'a> AddFrom<&'a Rational> for Float
impl AddFrom<i32> for Float
impl AddFrom<u32> for Float
impl AddFrom<f32> for Float
impl AddFrom<f64> for Float
impl<'a> AddFrom<MulRef<'a>> for Float
impl AddFrom<Complex> for Complex
impl<'a> AddFrom<&'a Complex> for Complex
impl AddFrom<Float> for Complex
impl<'a> AddFrom<&'a Float> for Complex
impl AddFrom<u32> for Complex
impl AddFrom<i32> for Complex
impl<'a> AddFrom<MulRef<'a>> for Complex