[][src]Struct ordered_float::NotNan

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

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

A NaN value cannot be stored in this type.

Methods

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 unsafe fn unchecked_new(val: T) -> Self[src]

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

Behaviour is undefined if val is NaN

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

Get the value out.

Trait Implementations

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

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

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

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

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

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

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

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

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

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

Creates a NotNan value from a Float.

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

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

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

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> 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> 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> 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> 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> Neg for NotNan<T>[src]

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 + 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<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 + 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 + 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> Deref for NotNan<T>[src]

type Target = T

The resulting type after dereferencing.

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

type Err = ParseNotNanError<T::Err>

The associated error which can be returned from parsing.

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: Clone + Float> Clone for NotNan<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

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

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

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

fn to_i128(&self) -> Option<i128>[src]

Converts the value of self to an i128. Read more

fn to_u128(&self) -> Option<u128>[src]

Converts the value of self to an u128. Read more

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

fn from_i128(n: i128) -> Option<Self>[src]

Convert an i128 to return an optional value of this type. If the type cannot be represented by this value, then None is returned. Read more

fn from_u128(n: u128) -> Option<Self>[src]

Convert an u128 to return an optional value of this type. If the type cannot be represented by this value, then None is returned. Read more

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

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

type FromStrRadixErr = ParseNotNanError<T::FromStrRadixErr>

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

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

fn is_one(&self) -> bool where
    Self: PartialEq<Self>, 
[src]

Returns true if self is equal to the multiplicative identity. Read more

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

Auto Trait Implementations

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

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

Blanket Implementations

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

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

impl<T, Rhs, Output> NumOps 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, Rhs> NumAssignOps for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

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

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

type Owned = T

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