Skip to main content

ShrExact

Trait ShrExact 

Source
pub trait ShrExact: Sized {
    type Output;

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

Performs a lossless (exactly reversible) right shift.

Required Associated Types§

Source

type Output

The result type (Self for the primitive impls).

Required Methods§

Source

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

type Output = i8

Source§

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

Source§

impl ShrExact for i16

Source§

type Output = i16

Source§

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

Source§

impl ShrExact for i32

Source§

type Output = i32

Source§

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

Source§

impl ShrExact for i64

Source§

type Output = i64

Source§

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

Source§

impl ShrExact for i128

Source§

type Output = i128

Source§

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

Source§

impl ShrExact for isize

Source§

type Output = isize

Source§

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

Source§

impl ShrExact for u8

Source§

type Output = u8

Source§

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

Source§

impl ShrExact for u16

Source§

type Output = u16

Source§

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

Source§

impl ShrExact for u32

Source§

type Output = u32

Source§

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

Source§

impl ShrExact for u64

Source§

type Output = u64

Source§

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

Source§

impl ShrExact for u128

Source§

type Output = u128

Source§

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

Source§

impl ShrExact for usize

Source§

type Output = usize

Source§

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

Implementors§