Trait Numeric

Source
pub 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>
    + BitAnd<Self, Output = Self>
    + BitOr<Self, Output = Self>
    + BitOrAssign<Self>
    + BitXor<Self, Output = Self>
    + Not<Output = Self>
    + Sub<Self, Output = Self> {
    const BITS_SIZE: u32;
    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn from_u8(u: u8) -> Self;
    fn to_u8(self) -> u8;
}
Expand description

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 Associated Constants§

Source

const BITS_SIZE: u32

Size of type in bits

Source

const ZERO: Self

The value of 0 in this type

Source

const ONE: Self

The value of 1 in this type

Required Methods§

Source

fn from_u8(u: u8) -> Self

Returns a u8 value in this type

Source

fn to_u8(self) -> u8

Assuming 0 <= value < 256, returns this value as a u8 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 Numeric for i8

Source§

const BITS_SIZE: u32 = 8u32

Source§

const ZERO: Self = 0i8

Source§

const ONE: Self = 1i8

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i16

Source§

const BITS_SIZE: u32 = 16u32

Source§

const ZERO: Self = 0i16

Source§

const ONE: Self = 1i16

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i32

Source§

const BITS_SIZE: u32 = 32u32

Source§

const ZERO: Self = 0i32

Source§

const ONE: Self = 1i32

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i64

Source§

const BITS_SIZE: u32 = 64u32

Source§

const ZERO: Self = 0i64

Source§

const ONE: Self = 1i64

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i128

Source§

const BITS_SIZE: u32 = 128u32

Source§

const ZERO: Self = 0i128

Source§

const ONE: Self = 1i128

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u8

Source§

const BITS_SIZE: u32 = 8u32

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u16

Source§

const BITS_SIZE: u32 = 16u32

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u32

Source§

const BITS_SIZE: u32 = 32u32

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u64

Source§

const BITS_SIZE: u32 = 64u32

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u128

Source§

const BITS_SIZE: u32 = 128u32

Source§

const ZERO: Self = 0u128

Source§

const ONE: Self = 1u128

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Implementors§