Skip to main content

ShlExact

Trait ShlExact 

Source
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§

Source

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".

Implementations on Foreign Types§

Source§

impl ShlExact for i8

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for i16

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for i32

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for i64

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for i128

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for isize

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for u8

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for u16

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for u32

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for u64

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for u128

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Source§

impl ShlExact for usize

Source§

fn shl_exact(self, rhs: u32) -> Option<Self>

Implementors§