Skip to main content

Numeric

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

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i16

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i32

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i64

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for i128

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u8

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u16

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u32

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u64

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Source§

impl Numeric for u128

Source§

const BITS_SIZE: u32

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

fn from_u8(u: u8) -> Self

Source§

fn to_u8(self) -> u8

Implementors§