Struct solstice::ClampedF32 [−][src]
pub struct ClampedF32(_);
Expand description
An non-NAN f32 value clamped between 0.0 and 1.0, inclusive. This type can be constructed with an f32 which will be clamped into the appropriate range.
Methods from Deref<Target = f32>
pub const RADIX: u32
1.43.0[src]
pub const MANTISSA_DIGITS: u32
1.43.0[src]
pub const DIGITS: u32
1.43.0[src]
pub const EPSILON: f32
1.43.0[src]
pub const MIN: f32
1.43.0[src]
pub const MIN_POSITIVE: f32
1.43.0[src]
pub const MAX: f32
1.43.0[src]
pub const MIN_EXP: i32
1.43.0[src]
pub const MAX_EXP: i32
1.43.0[src]
pub const MIN_10_EXP: i32
1.43.0[src]
pub const MAX_10_EXP: i32
1.43.0[src]
pub const NAN: f32
1.43.0[src]
pub const INFINITY: f32
1.43.0[src]
pub const NEG_INFINITY: f32
1.43.0[src]
pub fn total_cmp(&self, other: &f32) -> Ordering
[src]
🔬 This is a nightly-only experimental API. (total_cmp
)
pub fn total_cmp(&self, other: &f32) -> Ordering
[src]total_cmp
)Returns an ordering between self and other values. Unlike the standard partial comparison between floating point numbers, this comparison always produces an ordering in accordance to the totalOrder predicate as defined in IEEE 754 (2008 revision) floating point standard. The values are ordered in following order:
- Negative quiet NaN
- Negative signaling NaN
- Negative infinity
- Negative numbers
- Negative subnormal numbers
- Negative zero
- Positive zero
- Positive subnormal numbers
- Positive numbers
- Positive infinity
- Positive signaling NaN
- Positive quiet NaN
Note that this function does not always agree with the PartialOrd
and PartialEq
implementations of f32
. In particular, they regard
negative and positive zero as equal, while total_cmp
doesn’t.
Example
#![feature(total_cmp)] struct GoodBoy { name: String, weight: f32, } let mut bois = vec![ GoodBoy { name: "Pucci".to_owned(), weight: 0.1 }, GoodBoy { name: "Woofer".to_owned(), weight: 99.0 }, GoodBoy { name: "Yapper".to_owned(), weight: 10.0 }, GoodBoy { name: "Chonk".to_owned(), weight: f32::INFINITY }, GoodBoy { name: "Abs. Unit".to_owned(), weight: f32::NAN }, GoodBoy { name: "Floaty".to_owned(), weight: -5.0 }, ]; bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
Trait Implementations
impl Clone for ClampedF32
[src]
impl Clone for ClampedF32
[src]fn clone(&self) -> ClampedF32
[src]
fn clone(&self) -> ClampedF32
[src]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)
1.0.0[src]Performs copy-assignment from source
. Read more
impl Debug for ClampedF32
[src]
impl Debug for ClampedF32
[src]impl Default for ClampedF32
[src]
impl Default for ClampedF32
[src]fn default() -> ClampedF32
[src]
fn default() -> ClampedF32
[src]Returns the “default value” for a type. Read more
impl Deref for ClampedF32
[src]
impl Deref for ClampedF32
[src]impl Ord for ClampedF32
[src]
impl Ord for ClampedF32
[src]impl PartialEq<ClampedF32> for ClampedF32
[src]
impl PartialEq<ClampedF32> for ClampedF32
[src]fn eq(&self, other: &ClampedF32) -> bool
[src]
fn eq(&self, other: &ClampedF32) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &ClampedF32) -> bool
[src]
fn ne(&self, other: &ClampedF32) -> bool
[src]This method tests for !=
.
impl PartialOrd<ClampedF32> for ClampedF32
[src]
impl PartialOrd<ClampedF32> for ClampedF32
[src]fn partial_cmp(&self, other: &ClampedF32) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &ClampedF32) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for ClampedF32
[src]
impl Eq for ClampedF32
[src]
impl StructuralPartialEq for ClampedF32
[src]
Auto Trait Implementations
impl RefUnwindSafe for ClampedF32
impl Send for ClampedF32
impl Sync for ClampedF32
impl Unpin for ClampedF32
impl UnwindSafe for ClampedF32
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more