Skip to main content

Scalar

Trait Scalar 

Source
pub trait Scalar:
    Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Neg<Output = Self>
    + PartialOrd
    + Debug
    + Copy
    + 'static {
    // Required methods
    fn zero() -> Self;
    fn one() -> Self;
    fn from_usize(n: usize) -> Self;
}
Expand description

A scalar type suitable for arc-length, parameter, and distance computations.

Requires arithmetic operations (Add, Sub, Mul, Div, Neg), PartialOrd, Debug, Copy, and 'static bounds. Manual implementations are provided for f32 and f64.

Required Methods§

Source

fn zero() -> Self

Returns the additive identity (0.0).

Source

fn one() -> Self

Returns the multiplicative identity (1.0).

Source

fn from_usize(n: usize) -> Self

Cast a usize value to this scalar type.

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 Scalar for f32

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

impl Scalar for f64

Source§

fn zero() -> Self

Source§

fn one() -> Self

Source§

fn from_usize(n: usize) -> Self

Implementors§