Struct euclid::TypedScale [] [src]

#[repr(C)]
pub struct TypedScale<T, Src, Dst>(pub T, _);

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]

[src]

impl<T: Clone, Src, Dst> TypedScale<T, Src, Dst>
[src]

[src]

impl<T: Clone + One + Div<T, Output = T>, Src, Dst> TypedScale<T, Src, Dst>
[src]

[src]

The inverse TypedScale (1.0 / self).

impl<T: NumCast + Clone, Src, Dst0> TypedScale<T, Src, Dst0>
[src]

[src]

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]

[src]

Returns the given point transformed by this scale.

[src]

Returns the given vector transformed by this scale.

[src]

Returns the given vector transformed by this scale.

[src]

Returns the given rect transformed by this scale.

[src]

Returns the inverse of this scale.

[src]

Returns true if this scale has no effect.

Trait Implementations

impl<Src, Dst, T: Clone + Mul<T, Output = T>> Mul<TypedScale<T, Src, Dst>> for Length<T, Src>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<Src, Dst, T: Clone + Div<T, Output = T>> Div<TypedScale<T, Src, Dst>> for Length<T, Dst>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedPoint2D<T, U1>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedPoint2D<T, U2>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedRect<T, U1>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedRect<T, U2>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<T: Clone + Mul<T, Output = T>, A, B, C> Mul<TypedScale<T, B, C>> for TypedScale<T, A, B>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: Clone + Add<T, Output = T>, Src, Dst> Add for TypedScale<T, Src, Dst>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T: Clone + Sub<T, Output = T>, Src, Dst> Sub for TypedScale<T, Src, Dst>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<T: PartialEq, Src, Dst> PartialEq for TypedScale<T, Src, Dst>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<T: Clone, Src, Dst> Clone for TypedScale<T, Src, Dst>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Copy, Src, Dst> Copy for TypedScale<T, Src, Dst>
[src]

impl<T: Debug, Src, Dst> Debug for TypedScale<T, Src, Dst>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Display, Src, Dst> Display for TypedScale<T, Src, Dst>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedSize2D<T, U1>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedSize2D<T, U2>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedVector2D<T, U1>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedVector2D<T, U2>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

Auto Trait Implementations

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