Struct euclid::length::Length
[−]
[src]
pub struct Length<T, Unit>(pub T, _);
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_factor::ScaleFactor
to convert it from one unit to
another. See the ScaleFactor
docs for an example.
Methods
impl<T, Unit> Length<T, Unit>
[src]
impl<Unit, T: Clone> Length<T, Unit>
[src]
fn get(&self) -> T
impl<Unit, T0: NumCast + Clone> Length<T0, Unit>
[src]
fn cast<T1: NumCast + Clone>(&self) -> Option<Length<T1, Unit>>
Cast from one numeric representation to another, preserving the units.
Trait Implementations
impl<T: Decodable, Unit: Decodable> Decodable for Length<T, Unit>
[src]
fn decode<__DTUnit: Decoder>(__arg_0: &mut __DTUnit)
-> Result<Length<T, Unit>, __DTUnit::Error>
-> Result<Length<T, Unit>, __DTUnit::Error>
Deserialize a value using a Decoder
.
impl<T: Encodable, Unit: Encodable> Encodable for Length<T, Unit>
[src]
fn encode<__STUnit: Encoder>(&self,
__arg_0: &mut __STUnit)
-> Result<(), __STUnit::Error>
__arg_0: &mut __STUnit)
-> Result<(), __STUnit::Error>
Serialize a value using an Encoder
.
impl<T: Clone, Unit> Clone for Length<T, Unit>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Copy, Unit> Copy for Length<T, Unit>
[src]
impl<Unit, T: HeapSizeOf> HeapSizeOf for Length<T, Unit>
[src]
fn heap_size_of_children(&self) -> usize
Measure the size of any heap-allocated structures that hang off this value, but not the space taken up by the value itself (i.e. what size_of::
impl<Unit, T> Deserialize for Length<T, Unit> where T: Deserialize
[src]
fn deserialize<D>(deserializer: &mut D) -> Result<Length<T, Unit>, D::Error> where D: Deserializer
Deserialize this value given this Deserializer
.
impl<T, Unit> Serialize for Length<T, Unit> where T: Serialize
[src]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer
Serializes this value into this serializer.
impl<T: Debug + Clone, U> Debug for Length<T, U>
[src]
impl<T: Display + Clone, U> Display for Length<T, U>
[src]
impl<U, T: Clone + Add<T, Output=T>> Add for Length<T, U>
[src]
type Output = Length<T, U>
The resulting type after applying the +
operator
fn add(self, other: Length<T, U>) -> Length<T, U>
The method for the +
operator
impl<U, T: Clone + AddAssign<T>> AddAssign for Length<T, U>
[src]
fn add_assign(&mut self, other: Length<T, U>)
The method for the +=
operator
impl<U, T: Clone + Sub<T, Output=T>> Sub<Length<T, U>> for Length<T, U>
[src]
type Output = Length<T, U>
The resulting type after applying the -
operator
fn sub(self, other: Length<T, U>) -> Self::Output
The method for the -
operator
impl<U, T: Clone + SubAssign<T>> SubAssign for Length<T, U>
[src]
fn sub_assign(&mut self, other: Length<T, U>)
The method for the -=
operator
impl<U, T: Clone + Saturating> Saturating for Length<T, U>
[src]
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. Read more
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. Read more
impl<Src, Dst, T: Clone + Div<T, Output=T>> Div<Length<T, Src>> for Length<T, Dst>
[src]
type Output = ScaleFactor<T, Src, Dst>
The resulting type after applying the /
operator
fn div(self, other: Length<T, Src>) -> ScaleFactor<T, Src, Dst>
The method for the /
operator
impl<Src, Dst, T: Clone + Mul<T, Output=T>> Mul<ScaleFactor<T, Src, Dst>> for Length<T, Src>
[src]
type Output = Length<T, Dst>
The resulting type after applying the *
operator
fn mul(self, scale: ScaleFactor<T, Src, Dst>) -> Length<T, Dst>
The method for the *
operator
impl<Src, Dst, T: Clone + Div<T, Output=T>> Div<ScaleFactor<T, Src, Dst>> for Length<T, Dst>
[src]
type Output = Length<T, Src>
The resulting type after applying the /
operator
fn div(self, scale: ScaleFactor<T, Src, Dst>) -> Length<T, Src>
The method for the /
operator
impl<U, T: Clone + Neg<Output=T>> Neg for Length<T, U>
[src]
type Output = Length<T, U>
The resulting type after applying the -
operator
fn neg(self) -> Length<T, U>
The method for the unary -
operator
impl<Unit, T: Clone + PartialEq> PartialEq for Length<T, Unit>
[src]
fn eq(&self, other: &Length<T, Unit>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<Unit, T: Clone + PartialOrd> PartialOrd for Length<T, Unit>
[src]
fn partial_cmp(&self, other: &Length<T, Unit>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<Unit, T: Clone + Eq> Eq for Length<T, Unit>
[src]
impl<Unit, T: Clone + Ord> Ord for Length<T, Unit>
[src]
fn cmp(&self, other: &Length<T, Unit>) -> Ordering
This method returns an Ordering
between self
and other
. Read more