#[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§
Source§impl<U, T> AddAssign for Length<T, U>
impl<U, T> AddAssign for Length<T, U>
Source§fn add_assign(&mut self, other: Length<T, U>)
fn add_assign(&mut self, other: Length<T, U>)
Performs the
+=
operation. Read moreSource§impl<Src, Dst, T> Div<Length<T, Src>> for Length<T, Dst>
impl<Src, Dst, T> Div<Length<T, Src>> for Length<T, Dst>
Source§type Output = TypedScale<T, Src, Dst>
type Output = TypedScale<T, Src, Dst>
The resulting type after applying the
/
operator.Source§impl<Src, Dst, T> Div<TypedScale<T, Src, Dst>> for Length<T, Dst>
impl<Src, Dst, T> Div<TypedScale<T, Src, Dst>> for Length<T, Dst>
Source§impl<T, U> DivAssign<T> for Length<T, U>
impl<T, U> DivAssign<T> for Length<T, U>
Source§fn div_assign(&mut self, scale: T)
fn div_assign(&mut self, scale: T)
Performs the
/=
operation. Read moreSource§impl<Src, Dst, T> Mul<TypedScale<T, Src, Dst>> for Length<T, Src>
impl<Src, Dst, T> Mul<TypedScale<T, Src, Dst>> for Length<T, Src>
Source§impl<T, U> MulAssign<T> for Length<T, U>
impl<T, U> MulAssign<T> for Length<T, U>
Source§fn mul_assign(&mut self, scale: T)
fn mul_assign(&mut self, scale: T)
Performs the
*=
operation. Read moreSource§impl<Unit, T> Ord for Length<T, Unit>
impl<Unit, T> Ord for Length<T, Unit>
1.21.0 · Source§fn 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
Source§impl<Unit, T> PartialOrd for Length<T, Unit>where
T: Clone + PartialOrd,
impl<Unit, T> PartialOrd for Length<T, Unit>where
T: Clone + PartialOrd,
Source§impl<U, T> Saturating for Length<T, U>where
T: Clone + Saturating,
impl<U, T> Saturating for Length<T, U>where
T: Clone + Saturating,
Source§fn 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.
Source§fn 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.
Source§impl<U, T> SubAssign for Length<T, U>
impl<U, T> SubAssign for Length<T, U>
Source§fn sub_assign(&mut self, other: Length<T, U>)
fn sub_assign(&mut self, other: Length<T, U>)
Performs the
-=
operation. Read moreimpl<T, Unit> Copy for Length<T, Unit>where
T: Copy,
impl<Unit, T> Eq for Length<T, Unit>
Auto Trait Implementations§
impl<T, Unit> Freeze for Length<T, Unit>where
T: Freeze,
impl<T, Unit> RefUnwindSafe for Length<T, Unit>where
T: RefUnwindSafe,
Unit: RefUnwindSafe,
impl<T, Unit> Send for Length<T, Unit>
impl<T, Unit> Sync for Length<T, Unit>
impl<T, Unit> Unpin for Length<T, Unit>
impl<T, Unit> UnwindSafe for Length<T, Unit>where
T: UnwindSafe,
Unit: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more