Struct euclid::ScaleFactor [] [src]

#[repr(C)]
pub struct ScaleFactor<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 ScaleFactor. They may be types without values, such as empty enums. For example:

use euclid::ScaleFactor;
use euclid::Length;
enum Mm {};
enum Inch {};

let mm_per_inch: ScaleFactor<f32, Inch, Mm> = ScaleFactor::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> ScaleFactor<T, Src, Dst>
[src]

[src]

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

[src]

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

[src]

The inverse ScaleFactor (1.0 / self).

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

[src]

Cast from one numeric representation to another, preserving the units.

Trait Implementations

impl<T: HeapSizeOf, Src, Dst> HeapSizeOf for ScaleFactor<T, Src, Dst>
[src]

[src]

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:: measures, more or less); that space is handled by the implementation of HeapSizeOf for Box below. Read more

impl<'de, T, Src, Dst> Deserialize<'de> for ScaleFactor<T, Src, Dst> where
    T: Deserialize<'de>, 
[src]

[src]

Deserialize this value from the given Serde deserializer. Read more

impl<T, Src, Dst> Serialize for ScaleFactor<T, Src, Dst> where
    T: Serialize
[src]

[src]

Serialize this value into the given Serde serializer. Read more

impl<T: Clone + Mul<T, Output = T>, A, B, C> Mul<ScaleFactor<T, B, C>> for ScaleFactor<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 ScaleFactor<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 ScaleFactor<T, Src, Dst>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<T: PartialEq, Src, Dst> PartialEq for ScaleFactor<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 ScaleFactor<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 ScaleFactor<T, Src, Dst>
[src]

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

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter. Read more