Skip to main content

UnboundedShr

Trait UnboundedShr 

Source
pub trait UnboundedShr: Sized + Shr<u32> {
    // Required method
    fn unbounded_shr(self, rhs: u32) -> <Self as Shr<u32>>::Output;
}
Expand description

Performs a right shift that never panics, shifting in zero or sign bits for large shift amounts.

Required Methods§

Source

fn unbounded_shr(self, rhs: u32) -> <Self as Shr<u32>>::Output

Unbounded shift right. Computes self >> rhs, without bounding the value of rhs: if rhs >= BITS, unsigned values become 0 and signed values become 0 or -1 depending on the sign (the sign bit fills every position).

use const_num_traits::UnboundedShr;

assert_eq!(UnboundedShr::unbounded_shr(16u8, 4), 1);
assert_eq!(UnboundedShr::unbounded_shr(16u8, 200), 0);
assert_eq!(UnboundedShr::unbounded_shr(-16i8, 200), -1);

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 UnboundedShr for i8

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for i16

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for i32

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for i64

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for i128

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for isize

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for u8

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for u16

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for u32

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for u64

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for u128

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Source§

impl UnboundedShr for usize

Source§

fn unbounded_shr(self, rhs: u32) -> Self

Implementors§