Struct zng_layout::unit::euclid::Length
#[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
to convert it from one unit to
another. See the Scale
docs for an example.
Tuple Fields§
§0: T
Implementations§
§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<'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> 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> 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 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§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
Gets if
self
equals other
.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
§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
.§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
.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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