Trait Primitive

Source
pub trait Primitive: Operate + Sealed {
    type Signed: Primitive + Cast<Self>;
    type Unsigned: Primitive + Cast<Self>;

    const SIGNED: bool;
    const MIN: Self;
    const MAX: Self;
    const BITS: u8;
}
Expand description

Primitive trait for all primitive types.

Required Associated Constants§

Source

const SIGNED: bool

Whether this numeric primitive is singed or not.

Source

const MIN: Self

The minimum value of the primitive type.

Source

const MAX: Self

The maximum value of the primitive type.

Source

const BITS: u8

The number of bits in the primitive type.

Required Associated Types§

Source

type Signed: Primitive + Cast<Self>

The signed version of the primitive type.

Source

type Unsigned: Primitive + Cast<Self>

The unsigned version of the primitive 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 Primitive for i8

Source§

const SIGNED: bool = true

Source§

const MIN: Self = -128i8

Source§

const MAX: Self = 127i8

Source§

const BITS: u8 = 8u8

Source§

type Signed = i8

Source§

type Unsigned = u8

Source§

impl Primitive for i16

Source§

const SIGNED: bool = true

Source§

const MIN: Self = -32_768i16

Source§

const MAX: Self = 32_767i16

Source§

const BITS: u8 = 16u8

Source§

type Signed = i16

Source§

type Unsigned = u16

Source§

impl Primitive for i32

Source§

const SIGNED: bool = true

Source§

const MIN: Self = -2_147_483_648i32

Source§

const MAX: Self = 2_147_483_647i32

Source§

const BITS: u8 = 32u8

Source§

type Signed = i32

Source§

type Unsigned = u32

Source§

impl Primitive for i64

Source§

const SIGNED: bool = true

Source§

const MIN: Self = -9_223_372_036_854_775_808i64

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

const BITS: u8 = 64u8

Source§

type Signed = i64

Source§

type Unsigned = u64

Source§

impl Primitive for i128

Source§

const SIGNED: bool = true

Source§

const MIN: Self = -170_141_183_460_469_231_731_687_303_715_884_105_728i128

Source§

const MAX: Self = 170_141_183_460_469_231_731_687_303_715_884_105_727i128

Source§

const BITS: u8 = 128u8

Source§

type Signed = i128

Source§

type Unsigned = u128

Source§

impl Primitive for isize

Source§

const SIGNED: bool = true

Source§

const MIN: Self = -9_223_372_036_854_775_808isize

Source§

const MAX: Self = 9_223_372_036_854_775_807isize

Source§

const BITS: u8 = 64u8

Source§

type Signed = isize

Source§

type Unsigned = usize

Source§

impl Primitive for u8

Source§

const SIGNED: bool = false

Source§

const MIN: Self = 0u8

Source§

const MAX: Self = 255u8

Source§

const BITS: u8 = 8u8

Source§

type Signed = i8

Source§

type Unsigned = u8

Source§

impl Primitive for u16

Source§

const SIGNED: bool = false

Source§

const MIN: Self = 0u16

Source§

const MAX: Self = 65_535u16

Source§

const BITS: u8 = 16u8

Source§

type Signed = i16

Source§

type Unsigned = u16

Source§

impl Primitive for u32

Source§

const SIGNED: bool = false

Source§

const MIN: Self = 0u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

const BITS: u8 = 32u8

Source§

type Signed = i32

Source§

type Unsigned = u32

Source§

impl Primitive for u64

Source§

const SIGNED: bool = false

Source§

const MIN: Self = 0u64

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

const BITS: u8 = 64u8

Source§

type Signed = i64

Source§

type Unsigned = u64

Source§

impl Primitive for u128

Source§

const SIGNED: bool = false

Source§

const MIN: Self = 0u128

Source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

const BITS: u8 = 128u8

Source§

type Signed = i128

Source§

type Unsigned = u128

Source§

impl Primitive for usize

Source§

const SIGNED: bool = false

Source§

const MIN: Self = 0usize

Source§

const MAX: Self = 18_446_744_073_709_551_615usize

Source§

const BITS: u8 = 64u8

Source§

type Signed = isize

Source§

type Unsigned = usize

Implementors§