Trait Numeric

trait Numeric: Primitive + Sized + Copy + Default + Debug + PartialOrd + Shl<u32, Output = Self> + ShlAssign<u32> + Shr<u32, Output = Self> + ShrAssign<u32> + Rem<Self, Output = Self> + RemAssign<Self> + BitOrAssign<Self> + BitXor<Self, Output = Self> + Not<Output = Self> + Sub<Self, Output = Self>

This trait extends many common integer types (both unsigned and signed) with a few trivial methods so that they can be used with the bitstream handling traits.

Required Methods

fn is_zero(self: Self) -> bool

Returns true if this value is 0, in its type

fn from_u8(u: u8) -> Self

Returns a u8 value in this type

fn to_u8(self: Self) -> u8

Assuming 0 <= value < 256, returns this value as a u8 type

fn count_ones(self: Self) -> u32

Counts the number of 1 bits

fn leading_zeros(self: Self) -> u32

Counts the number of leading zeros

fn trailing_zeros(self: Self) -> u32

Counts the number of trailing zeros

fn unsigned_value(self: Self) -> UnsignedValue

Convert to a generic unsigned write value for stream recording purposes

Implementors