Struct euclid::Length [−][src]
#[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::Scale
to convert it from one unit to
another. See the Scale
docs for an example.
Implementations
impl<T: Clone, U> Length<T, U>
[src]
impl<T: Clone, U> Length<T, U>
[src]pub fn lerp(self, other: Self, t: T) -> Self where
T: One + Sub<Output = T> + Mul<Output = T> + Add<Output = T>,
[src]
pub fn lerp(self, other: Self, t: T) -> Self where
T: One + Sub<Output = T> + Mul<Output = T> + Add<Output = T>,
[src]Linearly interpolate between this length and another length.
Example
use euclid::default::Length; let from = Length::new(0.0); let to = Length::new(8.0); assert_eq!(from.lerp(to, -1.0), Length::new(-8.0)); assert_eq!(from.lerp(to, 0.0), Length::new( 0.0)); assert_eq!(from.lerp(to, 0.5), Length::new( 4.0)); assert_eq!(from.lerp(to, 1.0), Length::new( 8.0)); assert_eq!(from.lerp(to, 2.0), Length::new(16.0));
impl<T: PartialOrd, U> Length<T, U>
[src]
impl<T: PartialOrd, U> Length<T, U>
[src]Trait Implementations
impl<T: AddAssign, U> AddAssign<Length<T, U>> for Length<T, U>
[src]
impl<T: AddAssign, U> AddAssign<Length<T, U>> for Length<T, U>
[src]fn add_assign(&mut self, other: Self)
[src]
fn add_assign(&mut self, other: Self)
[src]Performs the +=
operation. Read more
impl<U, T: ApproxEq<T>> ApproxEq<T> for Length<T, U>
[src]
impl<U, T: ApproxEq<T>> ApproxEq<T> for Length<T, U>
[src]fn approx_epsilon() -> T
[src]
fn approx_epsilon() -> T
[src]Default epsilon value
impl<T: Copy + Div<T, Output = T>, U> DivAssign<T> for Length<T, U>
[src]
impl<T: Copy + Div<T, Output = T>, U> DivAssign<T> for Length<T, U>
[src]fn div_assign(&mut self, scale: T)
[src]
fn div_assign(&mut self, scale: T)
[src]Performs the /=
operation. Read more
impl<T: Copy + Mul<T, Output = T>, U> MulAssign<T> for Length<T, U>
[src]
impl<T: Copy + Mul<T, Output = T>, U> MulAssign<T> for Length<T, U>
[src]fn mul_assign(&mut self, scale: T)
[src]
fn mul_assign(&mut self, scale: T)
[src]Performs the *=
operation. Read more
impl<T: Ord, U> Ord for Length<T, U>
[src]
impl<T: Ord, U> Ord for Length<T, U>
[src]impl<T: PartialOrd, U> PartialOrd<Length<T, U>> for Length<T, U>
[src]
impl<T: PartialOrd, U> PartialOrd<Length<T, U>> for Length<T, U>
[src]fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Saturating, U> Saturating for Length<T, U>
[src]
impl<T: Saturating, U> Saturating for Length<T, U>
[src]fn saturating_add(self, other: Self) -> Self
[src]
fn saturating_add(self, other: Self) -> Self
[src]Saturating addition operator. Returns a+b, saturating at the numeric bounds instead of overflowing. Read more
fn saturating_sub(self, other: Self) -> Self
[src]
fn saturating_sub(self, other: Self) -> Self
[src]Saturating subtraction operator. Returns a-b, saturating at the numeric bounds instead of overflowing. Read more
impl<T: SubAssign, U> SubAssign<Length<T, U>> for Length<T, U>
[src]
impl<T: SubAssign, U> SubAssign<Length<T, U>> for Length<T, U>
[src]fn sub_assign(&mut self, other: Self)
[src]
fn sub_assign(&mut self, other: Self)
[src]Performs the -=
operation. Read more
impl<T: Copy, U> Copy for Length<T, U>
[src]
impl<T: Eq, U> Eq for Length<T, U>
[src]
Auto Trait Implementations
impl<T, Unit> RefUnwindSafe for Length<T, Unit> where
T: RefUnwindSafe,
Unit: RefUnwindSafe,
T: RefUnwindSafe,
Unit: RefUnwindSafe,
impl<T, Unit> Send for Length<T, Unit> where
T: Send,
Unit: Send,
T: Send,
Unit: Send,
impl<T, Unit> Sync for Length<T, Unit> where
T: Sync,
Unit: Sync,
T: Sync,
Unit: Sync,
impl<T, Unit> Unpin for Length<T, Unit> where
T: Unpin,
Unit: Unpin,
T: Unpin,
Unit: Unpin,
impl<T, Unit> UnwindSafe for Length<T, Unit> where
T: UnwindSafe,
Unit: UnwindSafe,
T: UnwindSafe,
Unit: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more