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§
sourcefn wrapping_shr(&self, rhs: u32) -> Self
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);
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl WrappingShr for i8
impl WrappingShr for i8
fn wrapping_shr(&self, rhs: u32) -> i8
source§impl WrappingShr for i16
impl WrappingShr for i16
fn wrapping_shr(&self, rhs: u32) -> i16
source§impl WrappingShr for i32
impl WrappingShr for i32
fn wrapping_shr(&self, rhs: u32) -> i32
source§impl WrappingShr for i64
impl WrappingShr for i64
fn wrapping_shr(&self, rhs: u32) -> i64
source§impl WrappingShr for i128
impl WrappingShr for i128
fn wrapping_shr(&self, rhs: u32) -> i128
source§impl WrappingShr for isize
impl WrappingShr for isize
fn wrapping_shr(&self, rhs: u32) -> isize
source§impl WrappingShr for u8
impl WrappingShr for u8
fn wrapping_shr(&self, rhs: u32) -> u8
source§impl WrappingShr for u16
impl WrappingShr for u16
fn wrapping_shr(&self, rhs: u32) -> u16
source§impl WrappingShr for u32
impl WrappingShr for u32
fn wrapping_shr(&self, rhs: u32) -> u32
source§impl WrappingShr for u64
impl WrappingShr for u64
fn wrapping_shr(&self, rhs: u32) -> u64
source§impl WrappingShr for u128
impl WrappingShr for u128
fn wrapping_shr(&self, rhs: u32) -> u128
source§impl WrappingShr for usize
impl WrappingShr for usize
fn wrapping_shr(&self, rhs: u32) -> usize
source§impl<T> WrappingShr for Wrapping<T>
impl<T> WrappingShr for Wrapping<T>
fn wrapping_shr(&self, rhs: u32) -> Wrapping<T>
Implementors§
impl WrappingShr for BoxedUint
Available on crate feature
alloc
only.