Skip to main content

Primitive

Trait Primitive 

Source
pub trait Primitive:
    Num
    + NumCast
    + Copy
    + PartialEq
    + SampleUniform
    + Debug
    + Display
    + Default {
    const HALF: 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;

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

Required Associated Constants§

Source

const HALF: 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

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", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Primitive for f32

Source§

const HALF: Self = 0.5

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§

impl Primitive for f64

Source§

const HALF: Self = 0.5

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§

impl Primitive for i8

Source§

const HALF: Self

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§

impl Primitive for i16

Source§

const HALF: Self

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§

impl Primitive for i32

Source§

const HALF: Self

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§

impl Primitive for i64

Source§

const HALF: Self

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§

impl Primitive for i128

Source§

const HALF: Self

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§

impl Primitive for u8

Source§

const HALF: Self

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§

impl Primitive for u16

Source§

const HALF: Self

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§

impl Primitive for u32

Source§

const HALF: Self

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§

impl Primitive for u64

Source§

const HALF: Self

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§

impl Primitive for u128

Source§

const HALF: Self

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

Implementors§