Skip to main content

UnboundedShr

Trait UnboundedShr 

Source
pub trait UnboundedShr: Sized {
    type Output;

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

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

Required Associated Types§

Source

type Output

The result type (Self for the primitive impls).

Required Methods§

Source

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

type Output = i8

Source§

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

Source§

impl UnboundedShr for i16

Source§

type Output = i16

Source§

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

Source§

impl UnboundedShr for i32

Source§

type Output = i32

Source§

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

Source§

impl UnboundedShr for i64

Source§

type Output = i64

Source§

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

Source§

impl UnboundedShr for i128

Source§

type Output = i128

Source§

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

Source§

impl UnboundedShr for isize

Source§

type Output = isize

Source§

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

Source§

impl UnboundedShr for u8

Source§

type Output = u8

Source§

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

Source§

impl UnboundedShr for u16

Source§

type Output = u16

Source§

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

Source§

impl UnboundedShr for u32

Source§

type Output = u32

Source§

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

Source§

impl UnboundedShr for u64

Source§

type Output = u64

Source§

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

Source§

impl UnboundedShr for u128

Source§

type Output = u128

Source§

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

Source§

impl UnboundedShr for usize

Source§

type Output = usize

Source§

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

Implementors§