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