Struct euclid::scale_factor::ScaleFactor
[−]
[src]
pub struct ScaleFactor<Src, Dst, T>(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::scale_factor::ScaleFactor; use euclid::length::Length; enum Mm {}; enum Inch {}; let mm_per_inch: ScaleFactor<Inch, Mm, f32> = ScaleFactor::new(25.4); let one_foot: Length<Inch, f32> = Length::new(12.0); let one_foot_in_mm: Length<Mm, f32> = one_foot * mm_per_inch;
Methods
impl<Src, Dst, T> ScaleFactor<Src, Dst, T>
[src]
fn new(x: T) -> ScaleFactor<Src, Dst, T>
impl<Src, Dst, T: Clone> ScaleFactor<Src, Dst, T>
[src]
fn get(&self) -> T
impl<Src, Dst, T: Clone + One + Div<T, Output=T>> ScaleFactor<Src, Dst, T>
[src]
fn inv(&self) -> ScaleFactor<Dst, Src, T>
The inverse ScaleFactor (1.0 / self).
impl<Src, Dst, T0: NumCast + Clone> ScaleFactor<Src, Dst, T0>
[src]
fn cast<T1: NumCast + Clone>(&self) -> Option<ScaleFactor<Src, Dst, T1>>
Cast from one numeric representation to another, preserving the units.
Trait Implementations
impl<Src: Debug, Dst: Debug, T: Debug> Debug for ScaleFactor<Src, Dst, T>
[src]
impl<Src: Encodable, Dst: Encodable, T: Encodable> Encodable for ScaleFactor<Src, Dst, T>
[src]
impl<Src: Decodable, Dst: Decodable, T: Decodable> Decodable for ScaleFactor<Src, Dst, T>
[src]
fn decode<__DSrcDstT: Decoder>(__arg_0: &mut __DSrcDstT) -> Result<ScaleFactor<Src, Dst, T>, __DSrcDstT::Error>
impl<Src: Copy, Dst: Copy, T: Copy> Copy for ScaleFactor<Src, Dst, T>
[src]
impl<Src, Dst, T> Deserialize for ScaleFactor<Src, Dst, T> where T: Deserialize
[src]
fn deserialize<D>(deserializer: &mut D) -> Result<ScaleFactor<Src, Dst, T>, D::Error> where D: Deserializer
Deserialize this value given this Deserializer
.
impl<Src, Dst, T> Serialize for ScaleFactor<Src, Dst, T> where T: Serialize
[src]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer
Serializes this value into this serializer.
impl<A, B, C, T: Clone + Mul<T, Output=T>> Mul<ScaleFactor<B, C, T>> for ScaleFactor<A, B, T>
[src]
type Output = ScaleFactor<A, C, T>
The resulting type after applying the *
operator
fn mul(self, other: ScaleFactor<B, C, T>) -> ScaleFactor<A, C, T>
The method for the *
operator
impl<Src, Dst, T: Clone + Add<T, Output=T>> Add for ScaleFactor<Src, Dst, T>
[src]
type Output = ScaleFactor<Src, Dst, T>
The resulting type after applying the +
operator
fn add(self, other: ScaleFactor<Src, Dst, T>) -> ScaleFactor<Src, Dst, T>
The method for the +
operator
impl<Src, Dst, T: Clone + Sub<T, Output=T>> Sub for ScaleFactor<Src, Dst, T>
[src]
type Output = ScaleFactor<Src, Dst, T>
The resulting type after applying the -
operator
fn sub(self, other: ScaleFactor<Src, Dst, T>) -> ScaleFactor<Src, Dst, T>
The method for the -
operator
impl<Src, Dst, T: Clone + PartialEq> PartialEq for ScaleFactor<Src, Dst, T>
[src]
fn eq(&self, other: &ScaleFactor<Src, Dst, T>) -> 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<Src, Dst, T: Clone> Clone for ScaleFactor<Src, Dst, T>
[src]
fn clone(&self) -> ScaleFactor<Src, Dst, T>
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