Trait Numeric

Source
pub trait Numeric:
    Sized
    + Copy
    + PartialEq
    + PartialOrd
    + CastFrom<Self>
    + Pod
    + Debug
    + Sync
    + Send
    + 'static {
    const BITS: usize;
    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;
    const MAX: Self;
}
Expand description

A trait implemented by any generic numeric type suitable for computations.

Required Associated Constants§

Source

const BITS: usize

This size of the type in bits.

Source

const ZERO: Self

The null element of the type.

Source

const ONE: Self

The identity element of the type.

Source

const TWO: Self

A value of two.

Source

const MAX: Self

The largest value that can be encoded by 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 Numeric for f32

Source§

const BITS: usize = 32usize

Source§

const ZERO: Self = 0f32

Source§

const ONE: Self = 1f32

Source§

const TWO: Self = 2f32

Source§

const MAX: Self = 3.40282347E+38f32

Source§

impl Numeric for f64

Source§

const BITS: usize = 64usize

Source§

const ZERO: Self = 0f64

Source§

const ONE: Self = 1f64

Source§

const TWO: Self = 2f64

Source§

const MAX: Self = 1.7976931348623157E+308f64

Source§

impl Numeric for i8

Source§

const BITS: usize = 8usize

Source§

const ZERO: Self = 0i8

Source§

const ONE: Self = 1i8

Source§

const TWO: Self = 2i8

Source§

const MAX: Self = 127i8

Source§

impl Numeric for i16

Source§

const BITS: usize = 16usize

Source§

const ZERO: Self = 0i16

Source§

const ONE: Self = 1i16

Source§

const TWO: Self = 2i16

Source§

const MAX: Self = 32_767i16

Source§

impl Numeric for i32

Source§

const BITS: usize = 32usize

Source§

const ZERO: Self = 0i32

Source§

const ONE: Self = 1i32

Source§

const TWO: Self = 2i32

Source§

const MAX: Self = 2_147_483_647i32

Source§

impl Numeric for i64

Source§

const BITS: usize = 64usize

Source§

const ZERO: Self = 0i64

Source§

const ONE: Self = 1i64

Source§

const TWO: Self = 2i64

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

impl Numeric for i128

Source§

const BITS: usize = 128usize

Source§

const ZERO: Self = 0i128

Source§

const ONE: Self = 1i128

Source§

const TWO: Self = 2i128

Source§

const MAX: Self = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

Source§

impl Numeric for isize

Source§

const BITS: usize = 64usize

Source§

const ZERO: Self = 0isize

Source§

const ONE: Self = 1isize

Source§

const TWO: Self = 2isize

Source§

const MAX: Self = 9_223_372_036_854_775_807isize

Source§

impl Numeric for u8

Source§

const BITS: usize = 8usize

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

const TWO: Self = 2u8

Source§

const MAX: Self = 255u8

Source§

impl Numeric for u16

Source§

const BITS: usize = 16usize

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

const TWO: Self = 2u16

Source§

const MAX: Self = 65_535u16

Source§

impl Numeric for u32

Source§

const BITS: usize = 32usize

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

const TWO: Self = 2u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

impl Numeric for u64

Source§

const BITS: usize = 64usize

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

const TWO: Self = 2u64

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

impl Numeric for u128

Source§

const BITS: usize = 128usize

Source§

const ZERO: Self = 0u128

Source§

const ONE: Self = 1u128

Source§

const TWO: Self = 2u128

Source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

impl Numeric for usize

Source§

const BITS: usize = 64usize

Source§

const ZERO: Self = 0usize

Source§

const ONE: Self = 1usize

Source§

const TWO: Self = 2usize

Source§

const MAX: Self = 18_446_744_073_709_551_615usize

Implementors§

Source§

impl<const N: usize> Numeric for StaticSignedBigInt<N>

Available on crate feature integer only.
Source§

const BITS: usize

Source§

const ZERO: Self = Self::ZERO

Source§

const ONE: Self = Self::ONE

Source§

const TWO: Self = Self::TWO

Source§

const MAX: Self = Self::MAX

Source§

impl<const N: usize> Numeric for StaticUnsignedBigInt<N>

Available on crate feature integer only.
Source§

const BITS: usize

Source§

const ZERO: Self = Self::ZERO

Source§

const ONE: Self = Self::ONE

Source§

const TWO: Self = Self::TWO

Source§

const MAX: Self = Self::MAX