Trait Num

Source
pub trait Num:
    Default
    + PartialEq
    + PartialOrd
    + Copy
    + AddAssign
    + MulAssign
    + SubAssign
    + DivAssign
    + Add<Output = Self>
    + Mul<Output = Self>
    + Sub<Output = Self>
    + Div<Output = Self> {
    // Required methods
    fn zero() -> Self;
    fn one() -> Self;
    fn two() -> Self;
    fn four() -> Self;
    fn get_max(self, b: Self) -> Self;
    fn get_min(self, b: Self) -> Self;
    fn saturating_sub(self, rhs: Self) -> Self;
    fn saturating_add(self, rhs: Self) -> Self;
    fn from_f32(value: f32) -> Self;
    fn to_f32(self) -> f32;
    fn round_up(self) -> Self;
    fn round_down(self) -> Self;
}
Expand description

A Number trait. Automatically implemented for primitive number types (i32, f32, etc).

Required Methods§

Source

fn zero() -> Self

Source

fn one() -> Self

Source

fn two() -> Self

Source

fn four() -> Self

Source

fn get_max(self, b: Self) -> Self

Source

fn get_min(self, b: Self) -> Self

Source

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

Source

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

Source

fn from_f32(value: f32) -> Self

Source

fn to_f32(self) -> f32

Source

fn round_up(self) -> Self

Source

fn round_down(self) -> Self

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§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_down(self) -> Self

Source§

fn round_up(self) -> Self

Source§

impl Num for f64

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_down(self) -> Self

Source§

fn round_up(self) -> Self

Source§

impl Num for i8

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for i16

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for i32

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for i64

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for isize

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for u8

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for u16

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for u32

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for u64

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Source§

impl Num for usize

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn two() -> Self

Source§

fn four() -> Self

Source§

fn get_max(self, b: Self) -> Self

Source§

fn get_min(self, b: Self) -> Self

Source§

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

Source§

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

Source§

fn from_f32(value: f32) -> Self

Source§

fn to_f32(self) -> f32

Source§

fn round_up(self) -> Self

Source§

fn round_down(self) -> Self

Implementors§