Skip to main content

ShrExact

Trait ShrExact 

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

Source

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

Implementations on Foreign Types§

Source§

impl ShrExact for i8

Source§

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

Source§

impl ShrExact for i16

Source§

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

Source§

impl ShrExact for i32

Source§

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

Source§

impl ShrExact for i64

Source§

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

Source§

impl ShrExact for i128

Source§

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

Source§

impl ShrExact for isize

Source§

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

Source§

impl ShrExact for u8

Source§

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

Source§

impl ShrExact for u16

Source§

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

Source§

impl ShrExact for u32

Source§

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

Source§

impl ShrExact for u64

Source§

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

Source§

impl ShrExact for u128

Source§

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

Source§

impl ShrExact for usize

Source§

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

Implementors§