[][src]Struct mag::Length

pub struct Length<U> where
    U: Unit
{ pub quantity: f64, // some fields omitted }

A measurement of physical length, distance or range.

Length is a base quantity with a specific unit.

Operations

  • Length + Length => Length
  • Length - Length => Length
  • Length * f64 => Length
  • f64 * Length => Length
  • f64 * unit => Length
  • Length * Length => Area
  • Length * unit => Area
  • Length / f64 => Length

Units must be the same for operations with two Length operands. The to method can be used for conversion.

Example

use mag::{Length, length::In};

let a = 5.5 * In;
let b = 4.5 * In;

assert_eq!(a.to_string(), "5.5 in");
assert_eq!(a + b, 10.0 * In);

Fields

quantity: f64

Length quantity

Methods

impl<U> Length<U> where
    U: Unit
[src]

pub fn new(quantity: f64) -> Self[src]

Create a new length measurement

pub fn to<T: Unit>(self) -> Length<T>[src]

Convert to specified units

Trait Implementations

impl<U: Clone> Clone for Length<U> where
    U: Unit
[src]

impl<U: Copy> Copy for Length<U> where
    U: Unit
[src]

impl<U: PartialEq> PartialEq<Length<U>> for Length<U> where
    U: Unit
[src]

impl<U> Display for Length<U> where
    U: Unit
[src]

impl<U: Debug> Debug for Length<U> where
    U: Unit
[src]

impl<U> Div<f64> for Length<U> where
    U: Unit
[src]

type Output = Self

The resulting type after applying the / operator.

impl<U> Div<Length<U>> for Area<U> where
    U: Unit
[src]

type Output = Length<U>

The resulting type after applying the / operator.

impl<U> Div<Length<U>> for Volume<U> where
    U: Unit
[src]

type Output = Area<U>

The resulting type after applying the / operator.

impl<L> Div<Gs> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, Gs>

The resulting type after applying the / operator.

impl<L> Div<Ms> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, Ms>

The resulting type after applying the / operator.

impl<L> Div<Ks> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, Ks>

The resulting type after applying the / operator.

impl<L> Div<wk> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, wk>

The resulting type after applying the / operator.

impl<L> Div<d> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, d>

The resulting type after applying the / operator.

impl<L> Div<h> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, h>

The resulting type after applying the / operator.

impl<L> Div<min> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, min>

The resulting type after applying the / operator.

impl<L> Div<s> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, s>

The resulting type after applying the / operator.

impl<L> Div<ds> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, ds>

The resulting type after applying the / operator.

impl<L> Div<ms> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, ms>

The resulting type after applying the / operator.

impl<L> Div<us> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, us>

The resulting type after applying the / operator.

impl<L> Div<ns> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, ns>

The resulting type after applying the / operator.

impl<L> Div<ps> for Length<L> where
    L: Unit
[src]

type Output = Speed<L, ps>

The resulting type after applying the / operator.

impl<L, T> Div<Period<T>> for Length<L> where
    L: Unit,
    T: Unit
[src]

type Output = Speed<L, T>

The resulting type after applying the / operator.

impl<U> Sub<Length<U>> for Length<U> where
    U: Unit
[src]

type Output = Self

The resulting type after applying the - operator.

impl<U> Add<Length<U>> for Length<U> where
    U: Unit
[src]

type Output = Self

The resulting type after applying the + operator.

impl Mul<km> for Length<km>[src]

type Output = Area<km>

The resulting type after applying the * operator.

impl Mul<m> for Length<m>[src]

type Output = Area<m>

The resulting type after applying the * operator.

impl Mul<dm> for Length<dm>[src]

type Output = Area<dm>

The resulting type after applying the * operator.

impl Mul<cm> for Length<cm>[src]

type Output = Area<cm>

The resulting type after applying the * operator.

impl Mul<mm> for Length<mm>[src]

type Output = Area<mm>

The resulting type after applying the * operator.

impl Mul<um> for Length<um>[src]

type Output = Area<um>

The resulting type after applying the * operator.

impl Mul<nm> for Length<nm>[src]

type Output = Area<nm>

The resulting type after applying the * operator.

impl Mul<mi> for Length<mi>[src]

type Output = Area<mi>

The resulting type after applying the * operator.

impl Mul<ft> for Length<ft>[src]

type Output = Area<ft>

The resulting type after applying the * operator.

impl Mul<In> for Length<In>[src]

type Output = Area<In>

The resulting type after applying the * operator.

impl Mul<yd> for Length<yd>[src]

type Output = Area<yd>

The resulting type after applying the * operator.

impl<U> Mul<f64> for Length<U> where
    U: Unit
[src]

type Output = Self

The resulting type after applying the * operator.

impl<U> Mul<Length<U>> for f64 where
    U: Unit
[src]

type Output = Length<U>

The resulting type after applying the * operator.

impl<U> Mul<Length<U>> for Length<U> where
    U: Unit
[src]

type Output = Area<U>

The resulting type after applying the * operator.

impl<U> Mul<Length<U>> for Area<U> where
    U: Unit
[src]

type Output = Volume<U>

The resulting type after applying the * operator.

impl<L, T> Mul<Length<L>> for Frequency<T> where
    L: Unit,
    T: Unit
[src]

type Output = Speed<L, T>

The resulting type after applying the * operator.

impl<L, T> Mul<Frequency<T>> for Length<L> where
    L: Unit,
    T: Unit
[src]

type Output = Speed<L, T>

The resulting type after applying the * operator.

impl<U> StructuralPartialEq for Length<U> where
    U: Unit
[src]

Auto Trait Implementations

impl<U> Send for Length<U> where
    U: Send

impl<U> Sync for Length<U> where
    U: Sync

impl<U> Unpin for Length<U> where
    U: Unpin

impl<U> UnwindSafe for Length<U> where
    U: UnwindSafe

impl<U> RefUnwindSafe for Length<U> where
    U: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]