[−][src]Struct euclid::TypedScale
A scaling factor between two different units of measurement.
This is effectively a type-safe float, intended to be used in combination with other types like
length::Length
to enforce conversion between systems of measurement at compile time.
Src
and Dst
represent the units before and after multiplying a value by a TypedScale
. They
may be types without values, such as empty enums. For example:
use euclid::TypedScale; use euclid::Length; enum Mm {}; enum Inch {}; let mm_per_inch: TypedScale<f32, Inch, Mm> = TypedScale::new(25.4); let one_foot: Length<f32, Inch> = Length::new(12.0); let one_foot_in_mm: Length<f32, Mm> = one_foot * mm_per_inch;
Methods
impl<T, Src, Dst> TypedScale<T, Src, Dst>
[src]
impl<T, Src, Dst> TypedScale<T, Src, Dst>
impl<T: Clone, Src, Dst> TypedScale<T, Src, Dst>
[src]
impl<T: Clone, Src, Dst> TypedScale<T, Src, Dst>
impl<Src, Dst> TypedScale<f32, Src, Dst>
[src]
impl<Src, Dst> TypedScale<f32, Src, Dst>
pub const ONE: Self
[src]
Identity scaling, could be used to safely transit from one space to another.
impl<T: Clone + One + Div<T, Output = T>, Src, Dst> TypedScale<T, Src, Dst>
[src]
impl<T: Clone + One + Div<T, Output = T>, Src, Dst> TypedScale<T, Src, Dst>
pub fn inv(&self) -> TypedScale<T, Dst, Src>
[src]
pub fn inv(&self) -> TypedScale<T, Dst, Src>
The inverse TypedScale (1.0 / self).
impl<T: NumCast + Clone, Src, Dst0> TypedScale<T, Src, Dst0>
[src]
impl<T: NumCast + Clone, Src, Dst0> TypedScale<T, Src, Dst0>
pub fn cast<T1: NumCast + Clone>(&self) -> TypedScale<T1, Src, Dst0>
[src]
pub fn cast<T1: NumCast + Clone>(&self) -> TypedScale<T1, Src, Dst0>
Cast from one numeric representation to another, preserving the units.
pub fn try_cast<T1: NumCast + Clone>(&self) -> Option<TypedScale<T1, Src, Dst0>>
[src]
pub fn try_cast<T1: NumCast + Clone>(&self) -> Option<TypedScale<T1, Src, Dst0>>
Fallible cast from one numeric representation to another, preserving the units.
impl<T, Src, Dst> TypedScale<T, Src, Dst> where
T: Copy + Clone + Mul<T, Output = T> + Neg<Output = T> + PartialEq + One,
[src]
impl<T, Src, Dst> TypedScale<T, Src, Dst> where
T: Copy + Clone + Mul<T, Output = T> + Neg<Output = T> + PartialEq + One,
pub fn transform_point(
&self,
point: &TypedPoint2D<T, Src>
) -> TypedPoint2D<T, Dst>
[src]
pub fn transform_point(
&self,
point: &TypedPoint2D<T, Src>
) -> TypedPoint2D<T, Dst>
Returns the given point transformed by this scale.
pub fn transform_vector(
&self,
vec: &TypedVector2D<T, Src>
) -> TypedVector2D<T, Dst>
[src]
pub fn transform_vector(
&self,
vec: &TypedVector2D<T, Src>
) -> TypedVector2D<T, Dst>
Returns the given vector transformed by this scale.
pub fn transform_size(&self, size: &TypedSize2D<T, Src>) -> TypedSize2D<T, Dst>
[src]
pub fn transform_size(&self, size: &TypedSize2D<T, Src>) -> TypedSize2D<T, Dst>
Returns the given vector transformed by this scale.
pub fn transform_rect(&self, rect: &TypedRect<T, Src>) -> TypedRect<T, Dst>
[src]
pub fn transform_rect(&self, rect: &TypedRect<T, Src>) -> TypedRect<T, Dst>
Returns the given rect transformed by this scale.
pub fn inverse(&self) -> TypedScale<T, Dst, Src>
[src]
pub fn inverse(&self) -> TypedScale<T, Dst, Src>
Returns the inverse of this scale.
pub fn is_identity(&self) -> bool
[src]
pub fn is_identity(&self) -> bool
Returns true if this scale has no effect.
Trait Implementations
impl<T: PartialEq, Src, Dst> PartialEq<TypedScale<T, Src, Dst>> for TypedScale<T, Src, Dst>
[src]
impl<T: PartialEq, Src, Dst> PartialEq<TypedScale<T, Src, Dst>> for TypedScale<T, Src, Dst>
fn eq(&self, other: &TypedScale<T, Src, Dst>) -> bool
[src]
fn eq(&self, other: &TypedScale<T, Src, Dst>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: Display, Src, Dst> Display for TypedScale<T, Src, Dst>
[src]
impl<T: Display, Src, Dst> Display for TypedScale<T, Src, Dst>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Debug, Src, Dst> Debug for TypedScale<T, Src, Dst>
[src]
impl<T: Debug, Src, Dst> Debug for TypedScale<T, Src, Dst>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Clone + Sub<T, Output = T>, Src, Dst> Sub<TypedScale<T, Src, Dst>> for TypedScale<T, Src, Dst>
[src]
impl<T: Clone + Sub<T, Output = T>, Src, Dst> Sub<TypedScale<T, Src, Dst>> for TypedScale<T, Src, Dst>
type Output = TypedScale<T, Src, Dst>
The resulting type after applying the -
operator.
fn sub(self, other: TypedScale<T, Src, Dst>) -> TypedScale<T, Src, Dst>
[src]
fn sub(self, other: TypedScale<T, Src, Dst>) -> TypedScale<T, Src, Dst>
Performs the -
operation.
impl<T: Clone + Add<T, Output = T>, Src, Dst> Add<TypedScale<T, Src, Dst>> for TypedScale<T, Src, Dst>
[src]
impl<T: Clone + Add<T, Output = T>, Src, Dst> Add<TypedScale<T, Src, Dst>> for TypedScale<T, Src, Dst>
type Output = TypedScale<T, Src, Dst>
The resulting type after applying the +
operator.
fn add(self, other: TypedScale<T, Src, Dst>) -> TypedScale<T, Src, Dst>
[src]
fn add(self, other: TypedScale<T, Src, Dst>) -> TypedScale<T, Src, Dst>
Performs the +
operation.
impl<Src, Dst, T: Clone + Mul<T, Output = T>> Mul<TypedScale<T, Src, Dst>> for Length<T, Src>
[src]
impl<Src, Dst, T: Clone + Mul<T, Output = T>> Mul<TypedScale<T, Src, Dst>> for Length<T, Src>
type Output = Length<T, Dst>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, Src, Dst>) -> Length<T, Dst>
[src]
fn mul(self, scale: TypedScale<T, Src, Dst>) -> Length<T, Dst>
Performs the *
operation.
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedPoint2D<T, U1>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedPoint2D<T, U1>
type Output = TypedPoint2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedPoint2D<T, U2>
[src]
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedPoint2D<T, U2>
Performs the *
operation.
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedRect<T, U1>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedRect<T, U1>
type Output = TypedRect<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U2>
[src]
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U2>
Performs the *
operation.
impl<T: Clone + Mul<T, Output = T>, A, B, C> Mul<TypedScale<T, B, C>> for TypedScale<T, A, B>
[src]
impl<T: Clone + Mul<T, Output = T>, A, B, C> Mul<TypedScale<T, B, C>> for TypedScale<T, A, B>
type Output = TypedScale<T, A, C>
The resulting type after applying the *
operator.
fn mul(self, other: TypedScale<T, B, C>) -> TypedScale<T, A, C>
[src]
fn mul(self, other: TypedScale<T, B, C>) -> TypedScale<T, A, C>
Performs the *
operation.
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedSize2D<T, U1>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedSize2D<T, U1>
type Output = TypedSize2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U2>
[src]
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U2>
Performs the *
operation.
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedVector2D<T, U1>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedVector2D<T, U1>
type Output = TypedVector2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, U1, U2>) -> Self::Output
[src]
fn mul(self, scale: TypedScale<T, U1, U2>) -> Self::Output
Performs the *
operation.
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedVector3D<T, U1>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedVector3D<T, U1>
type Output = TypedVector3D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, U1, U2>) -> Self::Output
[src]
fn mul(self, scale: TypedScale<T, U1, U2>) -> Self::Output
Performs the *
operation.
impl<Src, Dst, T: Clone + Div<T, Output = T>> Div<TypedScale<T, Src, Dst>> for Length<T, Dst>
[src]
impl<Src, Dst, T: Clone + Div<T, Output = T>> Div<TypedScale<T, Src, Dst>> for Length<T, Dst>
type Output = Length<T, Src>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, Src, Dst>) -> Length<T, Src>
[src]
fn div(self, scale: TypedScale<T, Src, Dst>) -> Length<T, Src>
Performs the /
operation.
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedPoint2D<T, U2>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedPoint2D<T, U2>
type Output = TypedPoint2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedPoint2D<T, U1>
[src]
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedPoint2D<T, U1>
Performs the /
operation.
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedRect<T, U2>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedRect<T, U2>
type Output = TypedRect<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U1>
[src]
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U1>
Performs the /
operation.
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedSize2D<T, U2>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedSize2D<T, U2>
type Output = TypedSize2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U1>
[src]
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedSize2D<T, U1>
Performs the /
operation.
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedVector2D<T, U2>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedVector2D<T, U2>
type Output = TypedVector2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, U1, U2>) -> Self::Output
[src]
fn div(self, scale: TypedScale<T, U1, U2>) -> Self::Output
Performs the /
operation.
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedVector3D<T, U2>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedVector3D<T, U2>
type Output = TypedVector3D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, U1, U2>) -> Self::Output
[src]
fn div(self, scale: TypedScale<T, U1, U2>) -> Self::Output
Performs the /
operation.
impl<T: Copy, Src, Dst> Copy for TypedScale<T, Src, Dst>
[src]
impl<T: Copy, Src, Dst> Copy for TypedScale<T, Src, Dst>
impl<T: Clone, Src, Dst> Clone for TypedScale<T, Src, Dst>
[src]
impl<T: Clone, Src, Dst> Clone for TypedScale<T, Src, Dst>
fn clone(&self) -> TypedScale<T, Src, Dst>
[src]
fn clone(&self) -> TypedScale<T, Src, Dst>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T, Src, Dst> Serialize for TypedScale<T, Src, Dst> where
T: Serialize,
[src]
impl<T, Src, Dst> Serialize for TypedScale<T, Src, Dst> where
T: Serialize,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de, T, Src, Dst> Deserialize<'de> for TypedScale<T, Src, Dst> where
T: Deserialize<'de>,
[src]
impl<'de, T, Src, Dst> Deserialize<'de> for TypedScale<T, Src, Dst> where
T: Deserialize<'de>,
fn deserialize<D>(deserializer: D) -> Result<TypedScale<T, Src, Dst>, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<TypedScale<T, Src, Dst>, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<T, Src, Dst> Send for TypedScale<T, Src, Dst> where
Dst: Send,
Src: Send,
T: Send,
impl<T, Src, Dst> Send for TypedScale<T, Src, Dst> where
Dst: Send,
Src: Send,
T: Send,
impl<T, Src, Dst> Sync for TypedScale<T, Src, Dst> where
Dst: Sync,
Src: Sync,
T: Sync,
impl<T, Src, Dst> Sync for TypedScale<T, Src, Dst> where
Dst: Sync,
Src: Sync,
T: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,