#[repr(C)]pub struct Length<T, Unit>(pub T, _);
Expand description
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.
Tuple Fields
0: T
Implementations
Trait Implementations
sourceimpl<U, T: Clone + AddAssign<T>> AddAssign<Length<T, U>> for Length<T, U>
impl<U, T: Clone + AddAssign<T>> AddAssign<Length<T, U>> for Length<T, U>
sourcefn add_assign(&mut self, other: Length<T, U>)
fn add_assign(&mut self, other: Length<T, U>)
Performs the
+=
operation. Read moresourceimpl<Src, Dst, T: Clone + Div<T, Output = T>> Div<Length<T, Src>> for Length<T, Dst>
impl<Src, Dst, T: Clone + Div<T, Output = T>> Div<Length<T, Src>> for Length<T, Dst>
type Output = TypedScale<T, Src, Dst>
type Output = TypedScale<T, Src, Dst>
The resulting type after applying the
/
operator.sourcefn div(self, other: Length<T, Src>) -> TypedScale<T, Src, Dst>
fn div(self, other: Length<T, Src>) -> TypedScale<T, Src, Dst>
Performs the
/
operation. Read moresourceimpl<T: Copy + Div<T, Output = T>, U> DivAssign<T> for Length<T, U>
impl<T: Copy + Div<T, Output = T>, U> DivAssign<T> for Length<T, U>
sourcefn div_assign(&mut self, scale: T)
fn div_assign(&mut self, scale: T)
Performs the
/=
operation. Read moresourceimpl<T: Copy + Mul<T, Output = T>, U> MulAssign<T> for Length<T, U>
impl<T: Copy + Mul<T, Output = T>, U> MulAssign<T> for Length<T, U>
sourcefn mul_assign(&mut self, scale: T)
fn mul_assign(&mut self, scale: T)
Performs the
*=
operation. Read moresourceimpl<Unit, T: Clone + Ord> Ord for Length<T, Unit>
impl<Unit, T: Clone + Ord> Ord for Length<T, Unit>
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<Unit, T: Clone + PartialEq> PartialEq<Length<T, Unit>> for Length<T, Unit>
impl<Unit, T: Clone + PartialEq> PartialEq<Length<T, Unit>> for Length<T, Unit>
sourceimpl<Unit, T: Clone + PartialOrd> PartialOrd<Length<T, Unit>> for Length<T, Unit>
impl<Unit, T: Clone + PartialOrd> PartialOrd<Length<T, Unit>> for Length<T, Unit>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl<U, T: Clone + Saturating> Saturating for Length<T, U>
impl<U, T: Clone + Saturating> Saturating for Length<T, U>
sourcefn saturating_add(self, other: Length<T, U>) -> Length<T, U>
fn saturating_add(self, other: Length<T, U>) -> Length<T, U>
Saturating addition operator.
Returns a+b, saturating at the numeric bounds instead of overflowing. Read more
sourcefn saturating_sub(self, other: Length<T, U>) -> Length<T, U>
fn saturating_sub(self, other: Length<T, U>) -> Length<T, U>
Saturating subtraction operator.
Returns a-b, saturating at the numeric bounds instead of overflowing. Read more
sourceimpl<U, T: Clone + SubAssign<T>> SubAssign<Length<T, U>> for Length<T, U>
impl<U, T: Clone + SubAssign<T>> SubAssign<Length<T, U>> for Length<T, U>
sourcefn sub_assign(&mut self, other: Length<T, U>)
fn sub_assign(&mut self, other: Length<T, U>)
Performs the
-=
operation. Read moreimpl<T: Copy, Unit> Copy for Length<T, Unit>
impl<Unit, T: Clone + Eq> Eq for Length<T, Unit>
Auto Trait Implementations
impl<T, Unit> RefUnwindSafe for Length<T, Unit>where
T: RefUnwindSafe,
Unit: RefUnwindSafe,
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> Unpin for Length<T, Unit>where
T: Unpin,
Unit: Unpin,
impl<T, Unit> UnwindSafe for Length<T, Unit>where
T: UnwindSafe,
Unit: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more