Struct zng_layout::unit::euclid::Length
source · #[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.
Tuple Fields§
§0: TImplementations§
source§impl<T, U> Length<T, U>where
T: Clone,
impl<T, U> Length<T, U>where
T: Clone,
sourcepub 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));source§impl<T, U> Length<T, U>where
T: PartialOrd,
impl<T, U> Length<T, U>where
T: PartialOrd,
Trait Implementations§
source§impl<T, U> AddAssign for Length<T, U>where
T: AddAssign,
impl<T, U> AddAssign for Length<T, U>where
T: AddAssign,
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<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>,
source§fn approx_epsilon() -> T
fn approx_epsilon() -> T
Default epsilon value
source§impl<'de, T, U> Deserialize<'de> for Length<T, U>where
T: Deserialize<'de>,
impl<'de, T, U> Deserialize<'de> for Length<T, U>where
T: Deserialize<'de>,
source§fn deserialize<D>(
deserializer: D
) -> Result<Length<T, U>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Length<T, U>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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<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<T, U> Ord for Length<T, U>where
T: Ord,
impl<T, U> Ord for Length<T, U>where
T: Ord,
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<T, U> PartialEq for Length<T, U>where
T: PartialEq,
impl<T, U> PartialEq for Length<T, U>where
T: PartialEq,
source§impl<T, U> PartialOrd for Length<T, U>where
T: PartialOrd,
impl<T, U> PartialOrd for Length<T, U>where
T: PartialOrd,
1.0.0 · source§fn 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 moresource§impl<T, U> Saturating for Length<T, U>where
T: Saturating,
impl<T, U> Saturating for Length<T, U>where
T: 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<T, U> Serialize for Length<T, U>where
T: Serialize,
impl<T, U> Serialize for Length<T, U>where
T: Serialize,
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl<T, U> SubAssign for Length<T, U>where
T: SubAssign,
impl<T, U> SubAssign for Length<T, U>where
T: SubAssign,
source§fn sub_assign(&mut self, other: Length<T, U>)
fn sub_assign(&mut self, other: Length<T, U>)
Performs the
-= operation. Read moresource§impl<T, U> Transitionable for Length<T, U>
impl<T, U> Transitionable for Length<T, U>
impl<T, U> Copy for Length<T, U>where
T: Copy,
impl<T, U> Eq for Length<T, U>where
T: Eq,
impl<T, U> Pod for Length<T, U>where
T: Pod,
U: 'static,
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> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Access to mut
dyn Any methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
Clone the value.
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
Clone the value into a new boxed
LocalVar<Self>.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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.