[][src]Struct ordered_float::NotNan

#[repr(transparent)]pub struct NotNan<T>(_);

A wrapper around Floats providing an implementation of Ord and Hash.

A NaN value cannot be stored in this type.

Implementations

impl<T> NotNan<T>[src]

pub const unsafe fn unchecked_new(val: T) -> Self[src]

Create a NotNan value from a value that is guaranteed to not be NaN

Safety

Behaviour is undefined if val is NaN

impl<T: Float> NotNan<T>[src]

pub fn new(val: T) -> Result<Self, FloatIsNan>[src]

Create a NotNan value.

Returns Err if val is NaN

pub fn into_inner(self) -> T[src]

Get the value out.

Trait Implementations

impl<T: Float> Add<NotNan<T>> for NotNan<T>[src]

Adds two NotNans.

Panics if the computation results in NaN

type Output = Self

The resulting type after applying the + operator.

impl<T: Float> Add<T> for NotNan<T>[src]

Adds a float directly.

Panics if the provided value is NaN or the computation results in NaN

type Output = Self

The resulting type after applying the + operator.

impl<T: Float + AddAssign> AddAssign<NotNan<T>> for NotNan<T>[src]

impl<T: Float + AddAssign> AddAssign<T> for NotNan<T>[src]

Adds a float directly.

Panics if the provided value is NaN.

impl<T: Float> AsRef<T> for NotNan<T>[src]

impl<T: Float> Bounded for NotNan<T>[src]

impl<T: Clone> Clone for NotNan<T>[src]

impl<T: Copy> Copy for NotNan<T>[src]

impl<T: Debug> Debug for NotNan<T>[src]

impl<T: Default> Default for NotNan<T>[src]

impl<T: Float> Deref for NotNan<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Float + Display> Display for NotNan<T>[src]

impl<T: Float> Div<NotNan<T>> for NotNan<T>[src]

type Output = Self

The resulting type after applying the / operator.

impl<T: Float> Div<T> for NotNan<T>[src]

Divides a float directly.

Panics if the provided value is NaN or the computation results in NaN

type Output = Self

The resulting type after applying the / operator.

impl<T: Float + DivAssign> DivAssign<NotNan<T>> for NotNan<T>[src]

impl<T: Float + DivAssign> DivAssign<T> for NotNan<T>[src]

Divides a float directly.

Panics if the provided value is NaN or the computation results in NaN

impl<T: Float + PartialEq> Eq for NotNan<T>[src]

impl From<NotNan<f32>> for f32[src]

impl From<NotNan<f32>> for NotNan<f64>[src]

impl From<NotNan<f64>> for f64[src]

impl<T: Float + FromPrimitive> FromPrimitive for NotNan<T>[src]

impl<T: Float + FromStr> FromStr for NotNan<T>[src]

type Err = ParseNotNanError<T::Err>

The associated error which can be returned from parsing.

pub fn from_str(src: &str) -> Result<Self, Self::Err>[src]

Convert a &str to NotNan. Returns an error if the string fails to parse, or if the resulting value is NaN

use ordered_float::NotNan;

assert!("-10".parse::<NotNan<f32>>().is_ok());
assert!("abc".parse::<NotNan<f32>>().is_err());
assert!("NaN".parse::<NotNan<f32>>().is_err());

impl<T: Float> Hash for NotNan<T>[src]

impl<T: Float> Mul<NotNan<T>> for NotNan<T>[src]

type Output = Self

The resulting type after applying the * operator.

impl<T: Float> Mul<T> for NotNan<T>[src]

Multiplies a float directly.

Panics if the provided value is NaN or the computation results in NaN

type Output = Self

The resulting type after applying the * operator.

impl<T: Float + MulAssign> MulAssign<NotNan<T>> for NotNan<T>[src]

impl<T: Float + MulAssign> MulAssign<T> for NotNan<T>[src]

Multiplies a float directly.

Panics if the provided value is NaN.

impl<T: Float> Neg for NotNan<T>[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: Float> Num for NotNan<T>[src]

type FromStrRadixErr = ParseNotNanError<T::FromStrRadixErr>

impl<T: Float> NumCast for NotNan<T>[src]

impl<T: Float> One for NotNan<T>[src]

impl<T: Float> Ord for NotNan<T>[src]

impl<T: PartialEq> PartialEq<NotNan<T>> for NotNan<T>[src]

impl<T: Float> PartialEq<T> for NotNan<T>[src]

impl<T: PartialOrd> PartialOrd<NotNan<T>> for NotNan<T>[src]

impl<'a, T: Float + Product + 'a> Product<&'a NotNan<T>> for NotNan<T>[src]

impl<T: Float + Product> Product<NotNan<T>> for NotNan<T>[src]

impl<T: Float> Rem<NotNan<T>> for NotNan<T>[src]

type Output = Self

The resulting type after applying the % operator.

impl<T: Float> Rem<T> for NotNan<T>[src]

Calculates % with a float directly.

Panics if the provided value is NaN or the computation results in NaN

type Output = Self

The resulting type after applying the % operator.

impl<T: Float + RemAssign> RemAssign<NotNan<T>> for NotNan<T>[src]

impl<T: Float + RemAssign> RemAssign<T> for NotNan<T>[src]

Calculates %= with a float directly.

Panics if the provided value is NaN or the computation results in NaN

impl<T: Float + Signed> Signed for NotNan<T>[src]

impl<T> StructuralPartialEq for NotNan<T>[src]

impl<T: Float> Sub<NotNan<T>> for NotNan<T>[src]

type Output = Self

The resulting type after applying the - operator.

impl<T: Float> Sub<T> for NotNan<T>[src]

Subtracts a float directly.

Panics if the provided value is NaN or the computation results in NaN

type Output = Self

The resulting type after applying the - operator.

impl<T: Float + SubAssign> SubAssign<NotNan<T>> for NotNan<T>[src]

impl<T: Float + SubAssign> SubAssign<T> for NotNan<T>[src]

Subtracts a float directly.

Panics if the provided value is NaN or the computation results in NaN

impl<'a, T: Float + Sum + 'a> Sum<&'a NotNan<T>> for NotNan<T>[src]

impl<T: Float + Sum> Sum<NotNan<T>> for NotNan<T>[src]

impl<T: Float> ToPrimitive for NotNan<T>[src]

impl TryFrom<f32> for NotNan<f32>[src]

type Error = FloatIsNan

The type returned in the event of a conversion error.

impl TryFrom<f64> for NotNan<f64>[src]

type Error = FloatIsNan

The type returned in the event of a conversion error.

impl<T: Float> Zero for NotNan<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for NotNan<T> where
    T: RefUnwindSafe

impl<T> Send for NotNan<T> where
    T: Send

impl<T> Sync for NotNan<T> where
    T: Sync

impl<T> Unpin for NotNan<T> where
    T: Unpin

impl<T> UnwindSafe for NotNan<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> NumAssign for T where
    T: Num + NumAssignOps<T>, 
[src]

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.