pub trait ShrExact: Sized + Shr<u32> {
// Required method
fn shr_exact(self, rhs: u32) -> Option<<Self as Shr<u32>>::Output>;
}Expand description
Performs a lossless (exactly reversible) right shift.
Required Methods§
Sourcefn shr_exact(self, rhs: u32) -> Option<<Self as Shr<u32>>::Output>
fn shr_exact(self, rhs: u32) -> Option<<Self as Shr<u32>>::Output>
Exact shift right. Computes self >> rhs if no one-bits would be
shifted out (so the operation can be losslessly reversed), None
otherwise.
use const_num_traits::ShrExact;
assert_eq!(ShrExact::shr_exact(0x88u8, 3), Some(0x11));
assert_eq!(ShrExact::shr_exact(0x88u8, 4), None);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".