Skip to main content

Quantity

Trait Quantity 

Source
pub trait Quantity:
    Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Percentage, Output = Self>
    + Mul<f32, Output = Self>
    + Div<f32, Output = Self>
    + Div<Self, Output = f32>
    + PartialOrd
    + Display
    + Copy
    + Clone
    + Debug
    + Default
    + Sized
    + Send
    + Sync {
    const MIN: Self;
    const MAX: Self;

    // Required methods
    fn abs(self) -> Self;
    fn floor(self) -> Self;
    fn ceil(self) -> Self;
    fn round(self) -> Self;
    fn trunc(self) -> Self;
    fn fract(self) -> Self;
    fn is_nan(self) -> bool;
    fn is_infinite(self) -> bool;
    fn min(self, other: Self) -> Self;
    fn max(self, other: Self) -> Self;

    // Provided method
    fn zero() -> Self { ... }
}
Expand description

A trait for physical quantities that supports basic arithmetic operations.

Required Associated Constants§

Source

const MIN: Self

Source

const MAX: Self

Required Methods§

Source

fn abs(self) -> Self

Source

fn floor(self) -> Self

Source

fn ceil(self) -> Self

Source

fn round(self) -> Self

Source

fn trunc(self) -> Self

Source

fn fract(self) -> Self

Source

fn is_nan(self) -> bool

Source

fn is_infinite(self) -> bool

Source

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

Source

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

Provided Methods§

Source

fn zero() -> 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 Quantity for f32

Source§

const MIN: Self = f32::MIN

Source§

const MAX: Self = f32::MAX

Source§

fn abs(self) -> Self

Source§

fn floor(self) -> Self

Source§

fn ceil(self) -> Self

Source§

fn round(self) -> Self

Source§

fn trunc(self) -> Self

Source§

fn fract(self) -> Self

Source§

fn is_nan(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

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

Source§

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

Implementors§

Source§

impl Quantity for Current

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Quantity for Energy

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Quantity for Frequency

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Quantity for Percentage

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Quantity for Power

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Quantity for ReactivePower

Source§

const MIN: Self

Source§

const MAX: Self

Source§

impl Quantity for Voltage

Source§

const MIN: Self

Source§

const MAX: Self