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);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so 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.