Skip to main content

ShlExact

Trait ShlExact 

Source
pub trait ShlExact: Sized {
    type Output;

    // Required method
    fn shl_exact(self, rhs: u32) -> Option<Self::Output>;
}
Expand description

Performs a lossless (exactly reversible) left shift.

Required Associated Types§

Source

type Output

The result type (Self for the primitive impls).

Required Methods§

Source

fn shl_exact(self, rhs: u32) -> Option<Self::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§

type Output = i8

Source§

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

Source§

impl ShlExact for i16

Source§

type Output = i16

Source§

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

Source§

impl ShlExact for i32

Source§

type Output = i32

Source§

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

Source§

impl ShlExact for i64

Source§

type Output = i64

Source§

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

Source§

impl ShlExact for i128

Source§

type Output = i128

Source§

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

Source§

impl ShlExact for isize

Source§

type Output = isize

Source§

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

Source§

impl ShlExact for u8

Source§

type Output = u8

Source§

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

Source§

impl ShlExact for u16

Source§

type Output = u16

Source§

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

Source§

impl ShlExact for u32

Source§

type Output = u32

Source§

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

Source§

impl ShlExact for u64

Source§

type Output = u64

Source§

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

Source§

impl ShlExact for u128

Source§

type Output = u128

Source§

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

Source§

impl ShlExact for usize

Source§

type Output = usize

Source§

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

Implementors§