Skip to main content

UnitType

Trait UnitType 

Source
pub trait UnitType:
    Debug
    + Copy
    + FromStr
    + PartialEq
    + PartialOrd
    + Serialize
    + Add
    + Sub
    + Div
    + Neg
    + Mul<Dimensionless, Output = Self>
    + AddAssign
    + SubAssign
    + Sum
    + ApproxEq<Margin = F64Margin>
    + Display {
    // Required methods
    fn new(value: f64) -> Self;
    fn value(&self) -> f64;
    fn is_normal(&self) -> bool;
    fn is_finite(&self) -> bool;
    fn abs(&self) -> Self;
    fn max(&self, other: Self) -> Self;
    fn min(&self, other: Self) -> Self;
    fn total_cmp(&self, other: &Self) -> Ordering;
}
Expand description

A trait encompassing most of the functionality of unit types

Required Methods§

Source

fn new(value: f64) -> Self

Create from an f64 value

Source

fn value(&self) -> f64

Returns the underlying f64 value.

Source

fn is_normal(&self) -> bool

Returns true if the value is a normal number.

Source

fn is_finite(&self) -> bool

Returns true if the value is finite.

Source

fn abs(&self) -> Self

Returns the absolute value of this unit.

Source

fn max(&self, other: Self) -> Self

Returns the max of two values

Source

fn min(&self, other: Self) -> Self

Returns the min of two values

Source

fn total_cmp(&self, other: &Self) -> Ordering

Returns ordering between self and other

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§