Struct Length
pub struct Length<T, Unit>(pub T, _);Available on crate feature 
geometry only.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 to convert it from one unit to
another. See the Scale docs for an example.
Tuple Fields§
§0: TImplementations§
§impl<T, U> Length<T, U>where
    T: Clone,
 
impl<T, U> Length<T, U>where
    T: Clone,
pub fn get(self) -> T
pub fn get(self) -> T
Unpack the underlying value from the wrapper.
pub fn lerp(self, other: Length<T, U>, t: T) -> Length<T, U>
pub fn lerp(self, other: Length<T, U>, t: T) -> Length<T, U>
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, U> Length<T, U>where
    T: PartialOrd,
 
impl<T, U> Length<T, U>where
    T: PartialOrd,
Trait Implementations§
§impl<T, U> AddAssign for Length<T, U>where
    T: AddAssign,
 
impl<T, U> AddAssign for Length<T, U>where
    T: AddAssign,
§fn add_assign(&mut self, other: Length<T, U>)
 
fn add_assign(&mut self, other: Length<T, U>)
Performs the 
+= operation. Read more§impl<U, T> ApproxEq<T> for Length<T, U>where
    T: ApproxEq<T>,
 
impl<U, T> ApproxEq<T> for Length<T, U>where
    T: ApproxEq<T>,
§fn approx_epsilon() -> T
 
fn approx_epsilon() -> T
Default epsilon value
§fn approx_eq_eps(&self, other: &Length<T, U>, approx_epsilon: &T) -> bool
 
fn approx_eq_eps(&self, other: &Length<T, U>, approx_epsilon: &T) -> bool
Returns 
true if this object is approximately equal to the other one, using
a provided epsilon value.§fn approx_eq(&self, other: &Self) -> bool
 
fn approx_eq(&self, other: &Self) -> bool
Returns 
true if this object is approximately equal to the other one, using
the approx_epsilon epsilon value.§impl<T, U> DivAssign<T> for Length<T, U>
 
impl<T, U> DivAssign<T> for Length<T, U>
§fn div_assign(&mut self, scale: T)
 
fn div_assign(&mut self, scale: T)
Performs the 
/= operation. Read more§impl<T, U> MulAssign<T> for Length<T, U>
 
impl<T, U> MulAssign<T> for Length<T, U>
§fn mul_assign(&mut self, scale: T)
 
fn mul_assign(&mut self, scale: T)
Performs the 
*= operation. Read more§impl<T, U> Ord for Length<T, U>where
    T: Ord,
 
impl<T, U> Ord for Length<T, U>where
    T: Ord,
§impl<T, U> PartialOrd for Length<T, U>where
    T: PartialOrd,
 
impl<T, U> PartialOrd for Length<T, U>where
    T: PartialOrd,
§impl<T, U> Saturating for Length<T, U>where
    T: Saturating,
 
impl<T, U> Saturating for Length<T, U>where
    T: Saturating,
§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.
§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.
§impl<T, U> SubAssign for Length<T, U>where
    T: SubAssign,
 
impl<T, U> SubAssign for Length<T, U>where
    T: SubAssign,
§fn sub_assign(&mut self, other: Length<T, U>)
 
fn sub_assign(&mut self, other: Length<T, U>)
Performs the 
-= operation. Read moreimpl<T, U> Copy for Length<T, U>where
    T: Copy,
impl<T, U> Eq for Length<T, U>where
    T: Eq,
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
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<Q, K> Comparable<K> for Q
 
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert 
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert 
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
Convert 
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert 
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
 
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
Compare self to 
key and return true if they are equal.§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
 
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
 
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
 
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as 
ReadEndian::read_from_little_endian().