Trait rug::Assign

source ·
pub trait Assign<Src = Self> {
    fn assign(&mut self, src: Src);
}
Expand description

Assigns to a number from another value.

Examples

Implementing the trait:

use rug::Assign;
struct I(i32);
impl Assign<i16> for I {
    fn assign(&mut self, rhs: i16) {
        self.0 = rhs.into();
    }
}
let mut i = I(0);
i.assign(42_i16);
assert_eq!(i.0, 42);

Performing an assignment operation using the trait:

use rug::{Assign, Integer};
let mut i = Integer::from(15);
assert_eq!(i, 15);
i.assign(23);
assert_eq!(i, 23);

Required Methods

Peforms the assignement.

Implementations on Foreign Types

Implementors