pub type Length = Length<f32, Measure>;
Aliased Type§
struct Length(pub f32);
Fields§
§0: f32
Implementations
§impl<T, U> Length<T, U>
impl<T, U> Length<T, U>
pub const fn new(x: T) -> Length<T, U>
pub const fn new(x: T) -> Length<T, U>
Associate a value with a unit of measure.
§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 cast_unit<V>(self) -> Length<T, V>
pub fn cast_unit<V>(self) -> Length<T, V>
Cast the unit
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,
§impl<T, U> Length<T, U>
impl<T, U> Length<T, U>
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<'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>,
§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
§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> PartialEq for Length<T, U>where
T: PartialEq,
impl<T, U> PartialEq for Length<T, U>where
T: PartialEq,
§impl<T, U> PartialOrd for Length<T, U>where
T: PartialOrd,
impl<T, U> PartialOrd for Length<T, U>where
T: PartialOrd,
§fn partial_cmp(&self, other: &Length<T, U>) -> Option<Ordering>
fn partial_cmp(&self, other: &Length<T, U>) -> Option<Ordering>
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 more§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> Serialize for Length<T, U>where
T: Serialize,
impl<T, U> Serialize for Length<T, U>where
T: Serialize,
§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
§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 more