[][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::TypedScale to convert it from one unit to another. See the TypedScale docs for an example.

Methods

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

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

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

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

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]

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<Unit, T: Clone + PartialEq> PartialEq<Length<T, Unit>> for Length<T, Unit>
[src]

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

This method tests for !=.

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

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

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

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

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

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

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

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

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

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

Formats the value using the given formatter. Read more

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

Formats the value using the given formatter. Read more

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

The resulting type after applying the - operator.

Performs the - operation.

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

The resulting type after applying the + operator.

Performs the + operation.

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

The resulting type after applying the * operator.

Performs the * operation.

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

The resulting type after applying the * operator.

Performs the * operation.

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

The resulting type after applying the / operator.

Performs the / operation.

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

The resulting type after applying the / operator.

Performs the / operation.

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

The resulting type after applying the / operator.

Performs the / operation.

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

The resulting type after applying the - operator.

Performs the unary - operation.

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

Performs the += operation.

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

Performs the -= operation.

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

Performs the *= operation.

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

Performs the /= operation.

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Serialize this value into the given Serde serializer. Read more

impl<'de, Unit, T> Deserialize<'de> for Length<T, Unit> where
    T: Deserialize<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

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

Saturating addition operator. Returns a+b, saturating at the numeric bounds instead of overflowing. Read more

Saturating subtraction operator. Returns a-b, saturating at the numeric bounds instead of overflowing. Read more

Auto Trait Implementations

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

Blanket Implementations

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

impl<T> From for T
[src]

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

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

Converts the given value to a String. Read more

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

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]