Trait rug::ops::MulFrom[][src]

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

Compound multiplication and assignment to the rhs operand.

rhs.mul_from(lhs) has the same effect as rhs = lhs * rhs.

Examples

use rug::ops::MulFrom;
struct ColumnVec(i32, i32);
struct SquareMatrix(ColumnVec, ColumnVec);
impl MulFrom<&SquareMatrix> for ColumnVec {
    fn mul_from(&mut self, lhs: &SquareMatrix) {
        let SquareMatrix(ref left, ref right) = *lhs;
        let out_0 = left.0 * self.0 + right.0 * self.1;
        self.1 = left.1 * self.0 + right.1 * self.1;
        self.0 = out_0;
    }
}
let mut col = ColumnVec(2, 30);
let matrix_left = ColumnVec(1, -2);
let matrix_right = ColumnVec(3, -1);
let matrix = SquareMatrix(matrix_left, matrix_right);
// ( 1   3) ( 2) = ( 92)
// (−2  −1) (30)   (−34)
col.mul_from(&matrix);
assert_eq!(col.0, 92);
assert_eq!(col.1, -34);

Required methods

fn mul_from(&mut self, lhs: Lhs)[src]

Peforms the multiplication.

Examples

use rug::{ops::MulFrom, Integer};
let mut rhs = Integer::from(5);
rhs.mul_from(50);
// rhs = 50 × 5
assert_eq!(rhs, 250);
Loading content...

Implementations on Foreign Types

impl MulFrom<i8> for i8[src]

impl MulFrom<&'_ i8> for i8[src]

impl MulFrom<i16> for i16[src]

impl MulFrom<&'_ i16> for i16[src]

impl MulFrom<i32> for i32[src]

impl MulFrom<&'_ i32> for i32[src]

impl MulFrom<i64> for i64[src]

impl MulFrom<&'_ i64> for i64[src]

impl MulFrom<i128> for i128[src]

impl MulFrom<&'_ i128> for i128[src]

impl MulFrom<isize> for isize[src]

impl MulFrom<&'_ isize> for isize[src]

impl MulFrom<u8> for u8[src]

impl MulFrom<&'_ u8> for u8[src]

impl MulFrom<u16> for u16[src]

impl MulFrom<&'_ u16> for u16[src]

impl MulFrom<u32> for u32[src]

impl MulFrom<&'_ u32> for u32[src]

impl MulFrom<u64> for u64[src]

impl MulFrom<&'_ u64> for u64[src]

impl MulFrom<u128> for u128[src]

impl MulFrom<&'_ u128> for u128[src]

impl MulFrom<usize> for usize[src]

impl MulFrom<&'_ usize> for usize[src]

impl MulFrom<f32> for f32[src]

impl MulFrom<&'_ f32> for f32[src]

impl MulFrom<f64> for f64[src]

impl MulFrom<&'_ f64> for f64[src]

Loading content...

Implementors

impl MulFrom<&'_ f32> for Float[src]

impl MulFrom<&'_ f64> for Float[src]

impl MulFrom<&'_ i8> for Float[src]

impl MulFrom<&'_ i8> for Integer[src]

impl MulFrom<&'_ i16> for Float[src]

impl MulFrom<&'_ i16> for Integer[src]

impl MulFrom<&'_ i32> for Float[src]

impl MulFrom<&'_ i32> for Integer[src]

impl MulFrom<&'_ i64> for Float[src]

impl MulFrom<&'_ i64> for Integer[src]

impl MulFrom<&'_ i128> for Float[src]

impl MulFrom<&'_ i128> for Integer[src]

impl MulFrom<&'_ u8> for Float[src]

impl MulFrom<&'_ u8> for Integer[src]

impl MulFrom<&'_ u16> for Float[src]

impl MulFrom<&'_ u16> for Integer[src]

impl MulFrom<&'_ u32> for Float[src]

impl MulFrom<&'_ u32> for Integer[src]

impl MulFrom<&'_ u64> for Float[src]

impl MulFrom<&'_ u64> for Integer[src]

impl MulFrom<&'_ u128> for Float[src]

impl MulFrom<&'_ u128> for Integer[src]

impl MulFrom<&'_ Float> for Float[src]

impl MulFrom<&'_ Integer> for Float[src]

impl MulFrom<&'_ Integer> for Integer[src]

impl MulFrom<f32> for Float[src]

impl MulFrom<f64> for Float[src]

impl MulFrom<i8> for Float[src]

impl MulFrom<i8> for Integer[src]

impl MulFrom<i16> for Float[src]

impl MulFrom<i16> for Integer[src]

impl MulFrom<i32> for Float[src]

impl MulFrom<i32> for Integer[src]

impl MulFrom<i64> for Float[src]

impl MulFrom<i64> for Integer[src]

impl MulFrom<i128> for Float[src]

impl MulFrom<i128> for Integer[src]

impl MulFrom<u8> for Float[src]

impl MulFrom<u8> for Integer[src]

impl MulFrom<u16> for Float[src]

impl MulFrom<u16> for Integer[src]

impl MulFrom<u32> for Float[src]

impl MulFrom<u32> for Integer[src]

impl MulFrom<u64> for Float[src]

impl MulFrom<u64> for Integer[src]

impl MulFrom<u128> for Float[src]

impl MulFrom<u128> for Integer[src]

impl MulFrom<Float> for Float[src]

impl MulFrom<Integer> for Float[src]

impl MulFrom<Integer> for Integer[src]

Loading content...