Struct euclid::length::Length [] [src]

pub struct Length<Unit, T>(pub T, _);

A one-dimensional distance, with value represented by T and unit of measurement Unit.

T can be any numeric type, for example a primitive type like u64 or f32.

Unit is not used in the representation of a Length value. It is used only at compile time to ensure that a Length stored with one unit is converted explicitly before being used in an expression that requires a different unit. It may be a type without values, such as an empty enum.

You can multiply a Length by a scale_factor::ScaleFactor to convert it from one unit to another. See the ScaleFactor docs for an example.

Methods

impl<Unit, T> Length<Unit, T>
[src]

fn new(x: T) -> Length<Unit, T>

impl<Unit, T: Clone> Length<Unit, T>
[src]

fn get(&self) -> T

impl<Unit, T0: NumCast + Clone> Length<Unit, T0>
[src]

fn cast<T1: NumCast + Clone>(&self) -> Option<Length<Unit, T1>>

Cast from one numeric representation to another, preserving the units.

Trait Implementations

impl<Unit: Debug, T: Debug> Debug for Length<Unit, T>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<Unit: Encodable, T: Encodable> Encodable for Length<Unit, T>
[src]

fn encode<__SUnitT: Encoder>(&self, __arg_0: &mut __SUnitT) -> Result<(), __SUnitT::Error>

impl<Unit: Decodable, T: Decodable> Decodable for Length<Unit, T>
[src]

fn decode<__DUnitT: Decoder>(__arg_0: &mut __DUnitT) -> Result<Length<Unit, T>, __DUnitT::Error>

impl<Unit: Copy, T: Copy> Copy for Length<Unit, T>
[src]

impl<U, T: Clone + Add<T, Output=T>> Add for Length<U, T>
[src]

type Output = Length<U, T>

The resulting type after applying the + operator

fn add(self, other: Length<U, T>) -> Length<U, T>

The method for the + operator

impl<U, T: Clone + AddAssign<T>> AddAssign for Length<U, T>
[src]

fn add_assign(&mut self, other: Length<U, T>)

The method for the += operator

impl<U, T: Clone + Sub<T, Output=T>> Sub<Length<U, T>> for Length<U, T>
[src]

type Output = Length<U, T>

The resulting type after applying the - operator

fn sub(self, other: Length<U, T>) -> Self::Output

The method for the - operator

impl<U, T: Clone + SubAssign<T>> SubAssign for Length<U, T>
[src]

fn sub_assign(&mut self, other: Length<U, T>)

The method for the -= operator

impl<Src, Dst, T: Clone + Div<T, Output=T>> Div<Length<Src, T>> for Length<Dst, T>
[src]

type Output = ScaleFactor<Src, Dst, T>

The resulting type after applying the / operator

fn div(self, other: Length<Src, T>) -> ScaleFactor<Src, Dst, T>

The method for the / operator

impl<Src, Dst, T: Clone + Mul<T, Output=T>> Mul<ScaleFactor<Src, Dst, T>> for Length<Src, T>
[src]

type Output = Length<Dst, T>

The resulting type after applying the * operator

fn mul(self, scale: ScaleFactor<Src, Dst, T>) -> Length<Dst, T>

The method for the * operator

impl<Src, Dst, T: Clone + Div<T, Output=T>> Div<ScaleFactor<Src, Dst, T>> for Length<Dst, T>
[src]

type Output = Length<Src, T>

The resulting type after applying the / operator

fn div(self, scale: ScaleFactor<Src, Dst, T>) -> Length<Src, T>

The method for the / operator

impl<U, T: Clone + Neg<Output=T>> Neg for Length<U, T>
[src]

type Output = Length<U, T>

The resulting type after applying the - operator

fn neg(self) -> Length<U, T>

The method for the unary - operator

impl<Unit, T: Clone> Clone for Length<Unit, T>
[src]

fn clone(&self) -> Length<Unit, T>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<Unit, T: Clone + PartialEq> PartialEq for Length<Unit, T>
[src]

fn eq(&self, other: &Length<Unit, T>) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

impl<Unit, T: Clone + PartialOrd> PartialOrd for Length<Unit, T>
[src]

fn partial_cmp(&self, other: &Length<Unit, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, other: &Rhs) -> bool
1.0.0

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Rhs) -> bool
1.0.0

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<Unit, T: Clone + Eq> Eq for Length<Unit, T>
[src]

impl<Unit, T: Clone + Ord> Ord for Length<Unit, T>
[src]

fn cmp(&self, other: &Length<Unit, T>) -> Ordering

This method returns an Ordering between self and other. Read more

impl<Unit, T: Zero> Zero for Length<Unit, T>
[src]

fn zero() -> Length<Unit, T>