Skip to main content

BitOps

Trait BitOps 

Source
pub trait BitOps:
    Copy
    + Clone
    + PartialEq
    + Eq
    + Hash
    + Debug
    + Sized
    + 'static {
    const ZERO: Self;
    const ONE: Self;
    const MAX: Self;
    const BITS: u32;

    // Required methods
    fn shl(self, n: u32) -> Self;
    fn shr(self, n: u32) -> Self;
    fn bitand(self, other: Self) -> Self;
    fn bitor(self, other: Self) -> Self;
    fn bitxor(self, other: Self) -> Self;
    fn not(self) -> Self;
    fn wrapping_sub(self, other: Self) -> Self;
    fn wrapping_add(self, other: Self) -> Self;
    fn to_u128(self) -> u128;
    fn from_u128(v: u128) -> Self;
    fn is_zero(self) -> bool;
    fn leading_zeros(self) -> u32;
}

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const MAX: Self

Source

const BITS: u32

Required Methods§

Source

fn shl(self, n: u32) -> Self

Source

fn shr(self, n: u32) -> Self

Source

fn bitand(self, other: Self) -> Self

Source

fn bitor(self, other: Self) -> Self

Source

fn bitxor(self, other: Self) -> Self

Source

fn not(self) -> Self

Source

fn wrapping_sub(self, other: Self) -> Self

Source

fn wrapping_add(self, other: Self) -> Self

Source

fn to_u128(self) -> u128

Source

fn from_u128(v: u128) -> Self

Source

fn is_zero(self) -> bool

Source

fn leading_zeros(self) -> u32

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 BitOps for u16

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const MAX: Self = u16::MAX

Source§

const BITS: u32 = u16::BITS

Source§

fn shl(self, n: u32) -> Self

Source§

fn shr(self, n: u32) -> Self

Source§

fn bitand(self, o: Self) -> Self

Source§

fn bitor(self, o: Self) -> Self

Source§

fn bitxor(self, o: Self) -> Self

Source§

fn not(self) -> Self

Source§

fn wrapping_sub(self, o: Self) -> Self

Source§

fn wrapping_add(self, o: Self) -> Self

Source§

fn to_u128(self) -> u128

Source§

fn from_u128(v: u128) -> Self

Source§

fn is_zero(self) -> bool

Source§

fn leading_zeros(self) -> u32

Source§

impl BitOps for u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const MAX: Self = u32::MAX

Source§

const BITS: u32 = u32::BITS

Source§

fn shl(self, n: u32) -> Self

Source§

fn shr(self, n: u32) -> Self

Source§

fn bitand(self, o: Self) -> Self

Source§

fn bitor(self, o: Self) -> Self

Source§

fn bitxor(self, o: Self) -> Self

Source§

fn not(self) -> Self

Source§

fn wrapping_sub(self, o: Self) -> Self

Source§

fn wrapping_add(self, o: Self) -> Self

Source§

fn to_u128(self) -> u128

Source§

fn from_u128(v: u128) -> Self

Source§

fn is_zero(self) -> bool

Source§

fn leading_zeros(self) -> u32

Source§

impl BitOps for u64

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const MAX: Self = u64::MAX

Source§

const BITS: u32 = u64::BITS

Source§

fn shl(self, n: u32) -> Self

Source§

fn shr(self, n: u32) -> Self

Source§

fn bitand(self, o: Self) -> Self

Source§

fn bitor(self, o: Self) -> Self

Source§

fn bitxor(self, o: Self) -> Self

Source§

fn not(self) -> Self

Source§

fn wrapping_sub(self, o: Self) -> Self

Source§

fn wrapping_add(self, o: Self) -> Self

Source§

fn to_u128(self) -> u128

Source§

fn from_u128(v: u128) -> Self

Source§

fn is_zero(self) -> bool

Source§

fn leading_zeros(self) -> u32

Source§

impl BitOps for u128

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const MAX: Self = u128::MAX

Source§

const BITS: u32 = u128::BITS

Source§

fn shl(self, n: u32) -> Self

Source§

fn shr(self, n: u32) -> Self

Source§

fn bitand(self, o: Self) -> Self

Source§

fn bitor(self, o: Self) -> Self

Source§

fn bitxor(self, o: Self) -> Self

Source§

fn not(self) -> Self

Source§

fn wrapping_sub(self, o: Self) -> Self

Source§

fn wrapping_add(self, o: Self) -> Self

Source§

fn to_u128(self) -> u128

Source§

fn from_u128(v: u128) -> Self

Source§

fn is_zero(self) -> bool

Source§

fn leading_zeros(self) -> u32

Implementors§