pub struct FiniteF32(/* private fields */);Expand description
Wrapper around f32 that guarantees a finite number, i.e., neither NaN
nor infinite. This makes the number orderable and sortable.
The type compares and calculates with f32 directly, so there is rarely
a need to unwrap it:
use spectrum_analyzer::FiniteF32;
let value = FiniteF32::from(0.5);
assert!(value > 0.25);
assert_eq!(value, 0.5);
assert_eq!(value * 2.0, 1.0);§Panics
Creating a value from an f32 that is not finite panics, and so does an
operation between two values of this type whose result is not finite.
Self::try_new checks instead.
Implementations§
Trait Implementations§
impl Copy for FiniteF32
impl Eq for FiniteF32
Source§impl Ord for FiniteF32
impl Ord for FiniteF32
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for FiniteF32
impl PartialOrd for FiniteF32
Source§impl PartialOrd<FiniteF32> for f32
impl PartialOrd<FiniteF32> for f32
Source§impl PartialOrd<f32> for FiniteF32
impl PartialOrd<f32> for FiniteF32
Auto Trait Implementations§
impl Freeze for FiniteF32
impl RefUnwindSafe for FiniteF32
impl Send for FiniteF32
impl Sync for FiniteF32
impl Unpin for FiniteF32
impl UnsafeUnpin for FiniteF32
impl UnwindSafe for FiniteF32
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more