Struct range_union_find::NonNanFloat
source · #[repr(transparent)]pub struct NonNanFloat<T: Float>(_);
Expand description
Wrapper for non-NaN floats that implements Eq and Ord.
Implementations§
source§impl<T: Float> NonNanFloat<T>
impl<T: Float> NonNanFloat<T>
sourcepub fn try_new(val: T) -> Result<Self, FloatIsNan>
pub fn try_new(val: T) -> Result<Self, FloatIsNan>
Try to wrap a float, returning an Error if the float is NaN.
pub fn into_inner(&self) -> T
Trait Implementations§
source§impl<T: Float> Add<NonNanFloat<T>> for NonNanFloat<T>
impl<T: Float> Add<NonNanFloat<T>> for NonNanFloat<T>
source§impl<T: Clone + Float> Clone for NonNanFloat<T>
impl<T: Clone + Float> Clone for NonNanFloat<T>
source§fn clone(&self) -> NonNanFloat<T>
fn clone(&self) -> NonNanFloat<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Default + Float> Default for NonNanFloat<T>
impl<T: Default + Float> Default for NonNanFloat<T>
source§fn default() -> NonNanFloat<T>
fn default() -> NonNanFloat<T>
Returns the “default value” for a type. Read more
source§impl<T: Float> Deref for NonNanFloat<T>
impl<T: Float> Deref for NonNanFloat<T>
source§impl From<NonNanFloat<f32>> for f32
impl From<NonNanFloat<f32>> for f32
source§fn from(value: NonNanFloat<f32>) -> Self
fn from(value: NonNanFloat<f32>) -> Self
Converts to this type from the input type.
source§impl From<NonNanFloat<f64>> for f64
impl From<NonNanFloat<f64>> for f64
source§fn from(value: NonNanFloat<f64>) -> Self
fn from(value: NonNanFloat<f64>) -> Self
Converts to this type from the input type.
source§impl Hash for NonNanFloat<f32>
impl Hash for NonNanFloat<f32>
source§impl Hash for NonNanFloat<f64>
impl Hash for NonNanFloat<f64>
source§impl<T: Float> NumInRange for NonNanFloat<T>where
NonNanFloat<T>: Steppable,
impl<T: Float> NumInRange for NonNanFloat<T>where NonNanFloat<T>: Steppable,
source§const MIN_DECR_IS_UNDERFLOW: bool = false
const MIN_DECR_IS_UNDERFLOW: bool = false
Whether caling
Steppable::step_decr
on the min value would underflow the type.source§const MAX_INCR_IS_OVERFLOW: bool = false
const MAX_INCR_IS_OVERFLOW: bool = false
Whether caling
Steppable::step_incr
on the max value would overflow the type.source§impl<T: Float> Ord for NonNanFloat<T>
impl<T: Float> Ord for NonNanFloat<T>
source§impl<T: PartialEq + Float> PartialEq<NonNanFloat<T>> for NonNanFloat<T>
impl<T: PartialEq + Float> PartialEq<NonNanFloat<T>> for NonNanFloat<T>
source§fn eq(&self, other: &NonNanFloat<T>) -> bool
fn eq(&self, other: &NonNanFloat<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: Float> PartialEq<T> for NonNanFloat<T>
impl<T: Float> PartialEq<T> for NonNanFloat<T>
source§impl<T: PartialOrd + Float> PartialOrd<NonNanFloat<T>> for NonNanFloat<T>
impl<T: PartialOrd + Float> PartialOrd<NonNanFloat<T>> for NonNanFloat<T>
source§fn partial_cmp(&self, other: &NonNanFloat<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &NonNanFloat<T>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<T: Float> PartialOrd<T> for NonNanFloat<T>
impl<T: Float> PartialOrd<T> for NonNanFloat<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Steppable for NonNanFloat<f32>
impl Steppable for NonNanFloat<f32>
Considerations for stepping floating-point types:
- Steps are performed to the next possible representable value, so the size of the step varies with the original number’s magnitude.
- Approximations and floating-point error can lead to miniscule gaps and other unexpected behaviors. For example, 0.3-0.2-0.1=-2.7755575615628914e-17 will not be contained in a nonnegative range starting at 0.
source§fn step_incr(&self) -> Self
fn step_incr(&self) -> Self
Return the smallest possible value larger than the input value. Should saturate at the maximum possible value.
source§fn step_decr(&self) -> Self
fn step_decr(&self) -> Self
Return the largest possible value smaller than the input value. Should saturate at the minimum possible value.
source§fn range_size<B: Borrow<Self>, R: RangeBounds<B>>(
range: R
) -> Result<Self, RangeOperationError>
fn range_size<B: Borrow<Self>, R: RangeBounds<B>>( range: R ) -> Result<Self, RangeOperationError>
Return the size of the range.
source§fn range_tuple_size<N: Borrow<Self>>(
start: N,
end: N
) -> Result<Self, RangeOperationError>
fn range_tuple_size<N: Borrow<Self>>( start: N, end: N ) -> Result<Self, RangeOperationError>
Functions like
Self::range_size
given input start..=end
.source§impl Steppable for NonNanFloat<f64>
impl Steppable for NonNanFloat<f64>
Considerations for stepping floating-point types:
- Steps are performed to the next possible representable value, so the size of the step varies with the original number’s magnitude.
- Approximations and floating-point error can lead to miniscule gaps and other unexpected behaviors. For example, 0.3-0.2-0.1=-2.7755575615628914e-17 will not be contained in a nonnegative range starting at 0.
source§fn step_incr(&self) -> Self
fn step_incr(&self) -> Self
Return the smallest possible value larger than the input value. Should saturate at the maximum possible value.
source§fn step_decr(&self) -> Self
fn step_decr(&self) -> Self
Return the largest possible value smaller than the input value. Should saturate at the minimum possible value.
source§fn range_size<B: Borrow<Self>, R: RangeBounds<B>>(
range: R
) -> Result<Self, RangeOperationError>
fn range_size<B: Borrow<Self>, R: RangeBounds<B>>( range: R ) -> Result<Self, RangeOperationError>
Return the size of the range.
source§fn range_tuple_size<N: Borrow<Self>>(
start: N,
end: N
) -> Result<Self, RangeOperationError>
fn range_tuple_size<N: Borrow<Self>>( start: N, end: N ) -> Result<Self, RangeOperationError>
Functions like
Self::range_size
given input start..=end
.impl<T: Copy + Float> Copy for NonNanFloat<T>
impl<T: Float> Eq for NonNanFloat<T>
impl<T: Float> StructuralPartialEq for NonNanFloat<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for NonNanFloat<T>where T: RefUnwindSafe,
impl<T> Send for NonNanFloat<T>where T: Send,
impl<T> Sync for NonNanFloat<T>where T: Sync,
impl<T> Unpin for NonNanFloat<T>where T: Unpin,
impl<T> UnwindSafe for NonNanFloat<T>where T: UnwindSafe,
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