Skip to main content

ConstUnboundedShift

Trait ConstUnboundedShift 

Source
pub trait ConstUnboundedShift: Sized {
    // Required methods
    fn unbounded_shl(self, rhs: u32) -> Self;
    fn unbounded_shr(self, rhs: u32) -> Self;
}
Expand description

Const-compatible unbounded shift operations.

Unlike regular shifts, unbounded shifts don’t panic when the shift amount exceeds the bit width. Instead:

  • unbounded_shl(n) returns 0 when n >= BITS (all bits shifted out)
  • unbounded_shr(n) returns 0 when n >= BITS (all bits shifted out)

Required Methods§

Source

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

Unbounded shift left. Returns 0 if rhs is greater than or equal to the bit width of the type.

Source

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

Unbounded shift right. Returns 0 if rhs is greater than or equal to the bit width of the type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ConstUnboundedShift for u8

Source§

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

Source§

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

Source§

impl ConstUnboundedShift for u16

Source§

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

Source§

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

Source§

impl ConstUnboundedShift for u32

Source§

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

Source§

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

Source§

impl ConstUnboundedShift for u64

Source§

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

Source§

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

Source§

impl ConstUnboundedShift for u128

Source§

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

Source§

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

Implementors§

Source§

impl<T: ConstMachineWord + MachineWord, const N: usize> ConstUnboundedShift for FixedUInt<T, N>