pub trait WrappingShr: Sized + Shr<usize, Output = Self> {
    // Required method
    fn wrapping_shr(&self, rhs: u32) -> Self;
}
Expand description

Performs a right shift that does not panic.

Required Methods§

source

fn wrapping_shr(&self, rhs: u32) -> Self

Panic-free bitwise shift-right; yields self >> mask(rhs), where mask removes any high order bits of rhs that would cause the shift to exceed the bitwidth of the type.

use num_traits::WrappingShr;

let x: u16 = 0x8000;

assert_eq!(WrappingShr::wrapping_shr(&x, 0),  0x8000);
assert_eq!(WrappingShr::wrapping_shr(&x, 1),  0x4000);
assert_eq!(WrappingShr::wrapping_shr(&x, 15), 0x0001);
assert_eq!(WrappingShr::wrapping_shr(&x, 16), 0x8000);

Implementations on Foreign Types§

source§

impl WrappingShr for u8

source§

fn wrapping_shr(&self, rhs: u32) -> u8

source§

impl<T: WrappingShr> WrappingShr for Wrapping<T>where Wrapping<T>: Shr<usize, Output = Wrapping<T>>,

source§

fn wrapping_shr(&self, rhs: u32) -> Self

source§

impl WrappingShr for i32

source§

fn wrapping_shr(&self, rhs: u32) -> i32

source§

impl WrappingShr for i8

source§

fn wrapping_shr(&self, rhs: u32) -> i8

source§

impl WrappingShr for u16

source§

fn wrapping_shr(&self, rhs: u32) -> u16

source§

impl WrappingShr for isize

source§

fn wrapping_shr(&self, rhs: u32) -> isize

source§

impl WrappingShr for i64

source§

fn wrapping_shr(&self, rhs: u32) -> i64

source§

impl WrappingShr for i128

source§

fn wrapping_shr(&self, rhs: u32) -> i128

source§

impl WrappingShr for usize

source§

fn wrapping_shr(&self, rhs: u32) -> usize

source§

impl WrappingShr for u64

source§

fn wrapping_shr(&self, rhs: u32) -> u64

source§

impl WrappingShr for u128

source§

fn wrapping_shr(&self, rhs: u32) -> u128

source§

impl WrappingShr for u32

source§

fn wrapping_shr(&self, rhs: u32) -> u32

source§

impl WrappingShr for i16

source§

fn wrapping_shr(&self, rhs: u32) -> i16

Implementors§