Trait rug::ops::ShlFrom[][src]

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

Compound left shift and assignment to the rhs operand.

rhs.shl_from(lhs) has the same effect as rhs = lhs << rhs.

Examples

use core::mem;
use rug::{ops::ShlFrom, Integer};
struct I(Integer);
impl ShlFrom for I {
    fn shl_from(&mut self, mut lhs: I) {
        let rhs = self.0.to_i32().expect("overflow");
        mem::swap(self, &mut lhs);
        self.0 <<= rhs;
    }
}
let mut i = I(Integer::from(200));
i.shl_from(I(Integer::from(0xf000)));
let expected = Integer::from(0xf000) << 200;
assert_eq!(i.0, expected);

Required methods

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

Peforms the left shift.

Examples

use rug::ops::ShlFrom;
let mut rhs = 4;
rhs.shl_from(0x00f0);
// rhs = 0x00f0 << 4
assert_eq!(rhs, 0x0f00);
Loading content...

Implementations on Foreign Types

impl ShlFrom<i8> for i8[src]

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

impl ShlFrom<i16> for i16[src]

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

impl ShlFrom<i32> for i32[src]

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

impl ShlFrom<i64> for i64[src]

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

impl ShlFrom<i128> for i128[src]

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

impl ShlFrom<isize> for isize[src]

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

impl ShlFrom<u8> for u8[src]

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

impl ShlFrom<u16> for u16[src]

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

impl ShlFrom<u32> for u32[src]

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

impl ShlFrom<u64> for u64[src]

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

impl ShlFrom<u128> for u128[src]

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

impl ShlFrom<usize> for usize[src]

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

Loading content...

Implementors

Loading content...