[][src]Trait rug::ops::ShrFrom

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

Compound right shift and assignment to the rhs operand.

rhs.shr_from(lhs) has the same effect as rhs = lhs >> rhs.

Examples

use core::mem;
use rug::{ops::ShrFrom, Integer};
struct I(Integer);
impl ShrFrom for I {
    fn shr_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(4));
i.shr_from(I(Integer::from(0xf000)));
let expected = Integer::from(0xf000) >> 4;
assert_eq!(i.0, expected);

Required methods

fn shr_from(&mut self, lhs: Lhs)

Peforms the right shift.

Examples

use rug::ops::ShrFrom;
let mut rhs = 4;
rhs.shr_from(0x00f0);
// rhs = 0x00f0 >> 4
assert_eq!(rhs, 0x000f);
Loading content...

Implementations on Foreign Types

impl ShrFrom<i8> for i8[src]

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

impl ShrFrom<i16> for i16[src]

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

impl ShrFrom<i32> for i32[src]

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

impl ShrFrom<i64> for i64[src]

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

impl ShrFrom<i128> for i128[src]

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

impl ShrFrom<isize> for isize[src]

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

impl ShrFrom<u8> for u8[src]

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

impl ShrFrom<u16> for u16[src]

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

impl ShrFrom<u32> for u32[src]

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

impl ShrFrom<u64> for u64[src]

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

impl ShrFrom<u128> for u128[src]

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

impl ShrFrom<usize> for usize[src]

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

Loading content...

Implementors

Loading content...