Struct closed01::Closed01
[−]
[src]
pub struct Closed01<F>(_)
where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat;
Encapsulates a floating point number in the range [0, 1] including both endpoints.
Methods
impl<F> Closed01<F> where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
[src]
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
fn new(f: F) -> Self
fn zero() -> Self
fn center() -> Self
fn one() -> Self
fn min(self, other: Self) -> Self
Returns the smaller of the two.
fn max(self, other: Self) -> Self
Returns the greater of the two.
fn distance(self, other: Self) -> Self
Returns the distance between the two numbers.
fn get(self) -> F
fn average(self, other: Self) -> Self
The average of two values.
fn saturating_add(self, other: Self) -> Self
Saturating add
fn saturating_sub(self, other: Self) -> Self
Saturating sub
fn mul(self, scalar: Self) -> Self
Multiplies both numbers
fn approx_eq(self, other: Self, eps: Self) -> bool
fn scale_up(self, other: Self) -> Self
This scales self
towards 1.0
fn scale_down(self, other: Self) -> Self
This scales self
towards 0.0
fn inv(self) -> Self
Invert the number (Mirror at 0.5; 1.0 - number).
fn round(self) -> Self
Round the number to 0.0 or 1.0
Trait Implementations
impl<F: Copy> Copy for Closed01<F> where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
[src]
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
impl<F: Clone> Clone for Closed01<F> where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
[src]
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
fn clone(&self) -> Closed01<F>
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<F: Debug> Debug for Closed01<F> where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
[src]
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
impl<F: PartialEq> PartialEq for Closed01<F> where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
[src]
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
fn eq(&self, __arg_0: &Closed01<F>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Closed01<F>) -> bool
This method tests for !=
.
impl<F: PartialOrd> PartialOrd for Closed01<F> where
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
[src]
F: Copy + Clone + Debug + PartialEq + PartialOrd + BaseFloat,
fn partial_cmp(&self, __arg_0: &Closed01<F>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Closed01<F>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Closed01<F>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Closed01<F>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Closed01<F>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Into<f32> for Closed01<f32>
[src]
impl Into<f64> for Closed01<f32>
[src]
impl Into<f32> for Closed01<f64>
[src]
impl Into<f64> for Closed01<f64>
[src]
impl Rand for Closed01<f32>
[src]
fn rand<R: Rng>(rng: &mut R) -> Self
Generates a random instance of this type using the specified source of randomness. Read more