pub trait Numeric: Copy + Clone + PartialEq + PartialOrd + Debug + Display + FromStr {
    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn rand(range: RangeInclusive<Self>) -> Self;
    fn from_usize(value: usize) -> Self;
    fn from_f64(value: f64) -> Self;
    fn to_usize(&self) -> usize;
    fn to_f64(&self) -> f64;

    // Provided method
    fn from<U: Numeric>(value: U) -> Self { ... }
}
Expand description

Numeric type for array

Required Associated Constants§

source

const ZERO: Self

Zero constant value

source

const ONE: Self

One constant value

Required Methods§

source

fn rand(range: RangeInclusive<Self>) -> Self

Generate random value

source

fn from_usize(value: usize) -> Self

Convert from usize

source

fn from_f64(value: f64) -> Self

Convert from f64

source

fn to_usize(&self) -> usize

Convert to usize

source

fn to_f64(&self) -> f64

Convert to f64

Provided Methods§

source

fn from<U: Numeric>(value: U) -> Self

Convert from any other numeric

Implementations on Foreign Types§

source§

impl Numeric for usize

source§

const ZERO: Self = 0usize

source§

const ONE: Self = 1usize

source§

fn rand(range: RangeInclusive<Self>) -> usize

source§

fn from_usize(value: usize) -> usize

source§

fn from_f64(value: f64) -> usize

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for f32

source§

const ZERO: Self = 0f32

source§

const ONE: Self = 1f32

source§

fn rand(range: RangeInclusive<Self>) -> f32

source§

fn from_usize(value: usize) -> f32

source§

fn from_f64(value: f64) -> f32

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for f64

source§

const ZERO: Self = 0f64

source§

const ONE: Self = 1f64

source§

fn rand(range: RangeInclusive<Self>) -> f64

source§

fn from_usize(value: usize) -> f64

source§

fn from_f64(value: f64) -> f64

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for i16

source§

const ZERO: Self = 0i16

source§

const ONE: Self = 1i16

source§

fn rand(range: RangeInclusive<Self>) -> i16

source§

fn from_usize(value: usize) -> i16

source§

fn from_f64(value: f64) -> i16

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for bool

source§

const ZERO: Self = false

source§

const ONE: Self = true

source§

fn rand(_: RangeInclusive<Self>) -> Self

source§

fn from_usize(value: usize) -> Self

source§

fn from_f64(value: f64) -> Self

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for i64

source§

const ZERO: Self = 0i64

source§

const ONE: Self = 1i64

source§

fn rand(range: RangeInclusive<Self>) -> i64

source§

fn from_usize(value: usize) -> i64

source§

fn from_f64(value: f64) -> i64

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for u32

source§

const ZERO: Self = 0u32

source§

const ONE: Self = 1u32

source§

fn rand(range: RangeInclusive<Self>) -> u32

source§

fn from_usize(value: usize) -> u32

source§

fn from_f64(value: f64) -> u32

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for u64

source§

const ZERO: Self = 0u64

source§

const ONE: Self = 1u64

source§

fn rand(range: RangeInclusive<Self>) -> u64

source§

fn from_usize(value: usize) -> u64

source§

fn from_f64(value: f64) -> u64

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for isize

source§

const ZERO: Self = 0isize

source§

const ONE: Self = 1isize

source§

fn rand(range: RangeInclusive<Self>) -> isize

source§

fn from_usize(value: usize) -> isize

source§

fn from_f64(value: f64) -> isize

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for u8

source§

const ZERO: Self = 0u8

source§

const ONE: Self = 1u8

source§

fn rand(range: RangeInclusive<Self>) -> u8

source§

fn from_usize(value: usize) -> u8

source§

fn from_f64(value: f64) -> u8

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for i8

source§

const ZERO: Self = 0i8

source§

const ONE: Self = 1i8

source§

fn rand(range: RangeInclusive<Self>) -> i8

source§

fn from_usize(value: usize) -> i8

source§

fn from_f64(value: f64) -> i8

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for u16

source§

const ZERO: Self = 0u16

source§

const ONE: Self = 1u16

source§

fn rand(range: RangeInclusive<Self>) -> u16

source§

fn from_usize(value: usize) -> u16

source§

fn from_f64(value: f64) -> u16

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

source§

impl Numeric for i32

source§

const ZERO: Self = 0i32

source§

const ONE: Self = 1i32

source§

fn rand(range: RangeInclusive<Self>) -> i32

source§

fn from_usize(value: usize) -> i32

source§

fn from_f64(value: f64) -> i32

source§

fn to_usize(&self) -> usize

source§

fn to_f64(&self) -> f64

Implementors§

source§

impl<N: Numeric> Numeric for Tuple2<N>

source§

const ZERO: Self = _

source§

const ONE: Self = _