Num

Trait Num 

Source
pub trait Num:
    Sealed
    + Numeric<AsU8 = u8, AsU16 = u16, AsU32 = u32, AsU64 = u64, AsU128 = u128, AsUSize = usize, AsI8 = i8, AsI16 = i16, AsI32 = i32, AsI64 = i64, AsI128 = i128, AsISize = isize, AsF32 = f32, AsF64 = f64>
    + Debug
    + Display
    + Copy
    + Clone
    + PartialEq<Self>
    + PartialOrd<Self>
    + Add<Self, Output = Self>
    + Sub<Self, Output = Self>
    + Div<Self, Output = Self>
    + Mul<Self, Output = Self>
    + Rem<Self, Output = Self>
    + AddAssign<Self>
    + SubAssign<Self>
    + MulAssign<Self>
    + DivAssign<Self>
    + RemAssign<Self> {
    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;
    const THREE: Self;
    const FOUR: Self;
    const MIN: Self;
    const MAX: Self;

    // Provided methods
    fn min(a: Self, b: Self) -> Self { ... }
    fn max(a: Self, b: Self) -> Self { ... }
    fn min_max(a: Self, b: Self) -> (Self, Self) { ... }
    fn clamp(x: Self, min: Self, max: Self) -> Self { ... }
}
Expand description

A primitive number type.

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Source

const THREE: Self

Source

const FOUR: Self

Source

const MIN: Self

Source

const MAX: Self

Provided Methods§

Source

fn min(a: Self, b: Self) -> Self

Returns the minimum of the numbers.

Source

fn max(a: Self, b: Self) -> Self

Returns the maximum of the numbers.

Source

fn min_max(a: Self, b: Self) -> (Self, Self)

Returns the two numbers as a tuple in ascending order.

Source

fn clamp(x: Self, min: Self, max: Self) -> Self

Clamps x between min and max.

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 Num for f32

Source§

const ZERO: Self = 0f32

Source§

const ONE: Self = 1f32

Source§

const TWO: Self = 2f32

Source§

const THREE: Self = 3f32

Source§

const FOUR: Self = 4f32

Source§

const MIN: Self = -3.40282347E+38f32

Source§

const MAX: Self = 3.40282347E+38f32

Source§

impl Num for f64

Source§

const ZERO: Self = 0f64

Source§

const ONE: Self = 1f64

Source§

const TWO: Self = 2f64

Source§

const THREE: Self = 3f64

Source§

const FOUR: Self = 4f64

Source§

const MIN: Self = -1.7976931348623157E+308f64

Source§

const MAX: Self = 1.7976931348623157E+308f64

Source§

impl Num for i8

Source§

const ZERO: Self = 0i8

Source§

const ONE: Self = 1i8

Source§

const TWO: Self = 2i8

Source§

const THREE: Self = 3i8

Source§

const FOUR: Self = 4i8

Source§

const MIN: Self = -128i8

Source§

const MAX: Self = 127i8

Source§

impl Num for i16

Source§

const ZERO: Self = 0i16

Source§

const ONE: Self = 1i16

Source§

const TWO: Self = 2i16

Source§

const THREE: Self = 3i16

Source§

const FOUR: Self = 4i16

Source§

const MIN: Self = -32_768i16

Source§

const MAX: Self = 32_767i16

Source§

impl Num for i32

Source§

const ZERO: Self = 0i32

Source§

const ONE: Self = 1i32

Source§

const TWO: Self = 2i32

Source§

const THREE: Self = 3i32

Source§

const FOUR: Self = 4i32

Source§

const MIN: Self = -2_147_483_648i32

Source§

const MAX: Self = 2_147_483_647i32

Source§

impl Num for i64

Source§

const ZERO: Self = 0i64

Source§

const ONE: Self = 1i64

Source§

const TWO: Self = 2i64

Source§

const THREE: Self = 3i64

Source§

const FOUR: Self = 4i64

Source§

const MIN: Self = -9_223_372_036_854_775_808i64

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

impl Num for i128

Source§

const ZERO: Self = 0i128

Source§

const ONE: Self = 1i128

Source§

const TWO: Self = 2i128

Source§

const THREE: Self = 3i128

Source§

const FOUR: Self = 4i128

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§

impl Num for isize

Source§

const ZERO: Self = 0isize

Source§

const ONE: Self = 1isize

Source§

const TWO: Self = 2isize

Source§

const THREE: Self = 3isize

Source§

const FOUR: Self = 4isize

Source§

const MIN: Self = -9_223_372_036_854_775_808isize

Source§

const MAX: Self = 9_223_372_036_854_775_807isize

Source§

impl Num for u8

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

const TWO: Self = 2u8

Source§

const THREE: Self = 3u8

Source§

const FOUR: Self = 4u8

Source§

const MIN: Self = 0u8

Source§

const MAX: Self = 255u8

Source§

impl Num for u16

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

const TWO: Self = 2u16

Source§

const THREE: Self = 3u16

Source§

const FOUR: Self = 4u16

Source§

const MIN: Self = 0u16

Source§

const MAX: Self = 65_535u16

Source§

impl Num for u32

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

const TWO: Self = 2u32

Source§

const THREE: Self = 3u32

Source§

const FOUR: Self = 4u32

Source§

const MIN: Self = 0u32

Source§

const MAX: Self = 4_294_967_295u32

Source§

impl Num for u64

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

const TWO: Self = 2u64

Source§

const THREE: Self = 3u64

Source§

const FOUR: Self = 4u64

Source§

const MIN: Self = 0u64

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

impl Num for u128

Source§

const ZERO: Self = 0u128

Source§

const ONE: Self = 1u128

Source§

const TWO: Self = 2u128

Source§

const THREE: Self = 3u128

Source§

const FOUR: Self = 4u128

Source§

const MIN: Self = 0u128

Source§

const MAX: Self = 340_282_366_920_938_463_463_374_607_431_768_211_455u128

Source§

impl Num for usize

Source§

const ZERO: Self = 0usize

Source§

const ONE: Self = 1usize

Source§

const TWO: Self = 2usize

Source§

const THREE: Self = 3usize

Source§

const FOUR: Self = 4usize

Source§

const MIN: Self = 0usize

Source§

const MAX: Self = 18_446_744_073_709_551_615usize

Implementors§