[][src]Trait const_linear::traits::Scalar

pub trait Scalar: Ops<Self> {
    const ZERO: Self;
    const ONE: Self;

    fn to_f64(self) -> f64;
fn to_f32(self) -> f32; }

A value which has some sensible notion of arithmetic, a Debug implementation, and is Copy. This trait is sealed, and can not be implemented outside of const_linear.

Examples

One and Zero values

use const_linear::traits::Scalar;

let x = i32::ZERO;
let y = i32::ONE;

assert_eq!(x - y, -1);

Converting to floating point

use const_linear::traits::Scalar;

assert_eq!(1.to_f64(), 1 as f64);
assert_eq!(1.to_f32(), 1 as f32);

Associated Constants

const ZERO: Self

The "zero" value for this Scalar type. Acts as the additive identity.

const ONE: Self

The "one" value for this Scalar type. Acts as the multiplicative identity.

Loading content...

Required methods

fn to_f64(self) -> f64

Converts T to an f64. Equivalent to T as f64.

fn to_f32(self) -> f32

Converts T to an f32. Equivalent to T as f32.

Loading content...

Implementations on Foreign Types

impl Scalar for i8[src]

impl Scalar for u8[src]

impl Scalar for i16[src]

impl Scalar for u16[src]

impl Scalar for i32[src]

impl Scalar for u32[src]

impl Scalar for i64[src]

impl Scalar for u64[src]

impl Scalar for i128[src]

impl Scalar for u128[src]

impl Scalar for isize[src]

impl Scalar for usize[src]

impl Scalar for f32[src]

impl Scalar for f64[src]

Loading content...

Implementors

Loading content...