[][src]Struct euclid::Length

#[repr(C)]
pub struct Length<T, Unit>(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::Scale to convert it from one unit to another. See the Scale docs for an example.

Methods

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

pub const fn new(x: T) -> Self[src]

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

pub fn get(&self) -> T[src]

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

pub fn cast<T1: NumCast + Clone>(&self) -> Length<T1, Unit>[src]

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

pub fn try_cast<T1: NumCast + Clone>(&self) -> Option<Length<T1, Unit>>[src]

Fallible cast from one numeric representation to another, preserving the units.

impl<T, U> Length<T, U> where
    T: Copy + One + Add<Output = T> + Sub<Output = T> + Mul<Output = T>, 
[src]

pub fn lerp(&self, other: Self, t: T) -> Self[src]

Linearly interpolate between this length and another length.

t is expected to be between zero and one.

Trait Implementations

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

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

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

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

type Output = Scale<T, Src, Dst>

The resulting type after applying the / operator.

impl<T: Copy + Div<T, Output = T>, U> Div<T> for Length<T, U>[src]

type Output = Self

The resulting type after applying the / operator.

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

type Output = Length<T, Src>

The resulting type after applying the / operator.

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

type Output = Length<T, U>

The resulting type after applying the - operator.

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

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

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

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

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

type Output = Length<T, U>

The resulting type after applying the + operator.

impl<T: Copy + Mul<T, Output = T>, U> Mul<T> for Length<T, U>[src]

type Output = Self

The resulting type after applying the * operator.

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

type Output = Length<T, Dst>

The resulting type after applying the * operator.

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

type Output = Length<T, U>

The resulting type after applying the - operator.

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

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

impl<T: Copy + Mul<T, Output = T>, U> MulAssign<T> for Length<T, U>[src]

impl<T: Copy + Div<T, Output = T>, U> DivAssign<T> for Length<T, U>[src]

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

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

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

Auto Trait Implementations

impl<T, Unit> Unpin for Length<T, Unit> where
    T: Unpin,
    Unit: Unpin

impl<T, Unit> Send for Length<T, Unit> where
    T: Send,
    Unit: Send

impl<T, Unit> Sync for Length<T, Unit> where
    T: Sync,
    Unit: Sync

impl<T, Unit> UnwindSafe for Length<T, Unit> where
    T: UnwindSafe,
    Unit: UnwindSafe

impl<T, Unit> RefUnwindSafe for Length<T, Unit> where
    T: RefUnwindSafe,
    Unit: RefUnwindSafe

Blanket Implementations

impl<T> Zero for T where
    T: Zero
[src]

impl<T> From<T> for T[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> Into<U> for T where
    U: From<T>, 
[src]

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]

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]