Skip to main content

Primitive

Trait Primitive 

Source
pub trait Primitive:
    Num
    + NumCast
    + Copy
    + PartialEq
    + SampleUniform
    + Debug
    + Display
    + Default
    + PartialOrd {
    const HALF: Self;
    const MIN: Self;
    const MAX: Self;
    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;

    // Required methods
    fn safe_add(self, rhs: Self) -> Self;
    fn safe_sub(self, rhs: Self) -> Self;
    fn safe_mul(self, rhs: Self) -> Self;
    fn safe_div(self, rhs: Self) -> Self;
    fn safe_mean(self, rhs: Self) -> Self;
    fn is_equal(self, rhs: Self) -> bool;

    // Provided method
    fn extract<T: NumCast>(self) -> Option<T> { ... }
}

Required Associated Constants§

Source

const HALF: Self

Source

const MIN: Self

Source

const MAX: Self

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Required Methods§

Source

fn safe_add(self, rhs: Self) -> Self

Source

fn safe_sub(self, rhs: Self) -> Self

Source

fn safe_mul(self, rhs: Self) -> Self

Source

fn safe_div(self, rhs: Self) -> Self

Source

fn safe_mean(self, rhs: Self) -> Self

Source

fn is_equal(self, rhs: Self) -> bool

Provided Methods§

Source

fn extract<T: NumCast>(self) -> Option<T>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Primitive for f32

Source§

const HALF: Self = 0.5

Source§

const MIN: Self = f32::MIN

Source§

const MAX: Self = f32::MAX

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

const TWO: Self = 2.0

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for f64

Source§

const HALF: Self = 0.5

Source§

const MIN: Self = f64::MIN

Source§

const MAX: Self = f64::MAX

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

const TWO: Self = 2.0

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for i8

Source§

const HALF: Self

Source§

const MIN: Self = i8::MIN

Source§

const MAX: Self = i8::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for i16

Source§

const HALF: Self

Source§

const MIN: Self = i16::MIN

Source§

const MAX: Self = i16::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for i32

Source§

const HALF: Self

Source§

const MIN: Self = i32::MIN

Source§

const MAX: Self = i32::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for i64

Source§

const HALF: Self

Source§

const MIN: Self = i64::MIN

Source§

const MAX: Self = i64::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for i128

Source§

const HALF: Self

Source§

const MIN: Self = i128::MIN

Source§

const MAX: Self = i128::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for u8

Source§

const HALF: Self

Source§

const MIN: Self = u8::MIN

Source§

const MAX: Self = u8::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for u16

Source§

const HALF: Self

Source§

const MIN: Self = u16::MIN

Source§

const MAX: Self = u16::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for u32

Source§

const HALF: Self

Source§

const MIN: Self = u32::MIN

Source§

const MAX: Self = u32::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for u64

Source§

const HALF: Self

Source§

const MIN: Self = u64::MIN

Source§

const MAX: Self = u64::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Source§

impl Primitive for u128

Source§

const HALF: Self

Source§

const MIN: Self = u128::MIN

Source§

const MAX: Self = u128::MAX

Source§

const ZERO: Self = 0

Source§

const ONE: Self = 1

Source§

const TWO: Self = 2

Source§

fn safe_add(self, rhs: Self) -> Self

Source§

fn safe_sub(self, rhs: Self) -> Self

Source§

fn safe_mul(self, rhs: Self) -> Self

Source§

fn safe_div(self, rhs: Self) -> Self

Source§

fn safe_mean(self, rhs: Self) -> Self

Source§

fn is_equal(self, rhs: Self) -> bool

Implementors§