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.