Struct noisy_float::NoisyFloat[][src]

#[repr(transparent)]pub struct NoisyFloat<F: Float, C: FloatChecker<F>> { /* fields omitted */ }

A floating point number with a restricted set of legal values.

Typical users will not need to access this struct directly, but can instead use the type aliases found in the module noisy_float::types. However, this struct together with a FloatChecker implementation can be used to define custom behavior.

The underlying float type is F, usually f32 or f64. Valid values for the float are determined by the float checker C. If an invalid value would ever be returned from a method on this type, the method will panic instead, using either assert! or debug_assert! as defined by the float checker. The exception to this rule is for methods that return an Option containing a NoisyFloat, in which case the result would be None if the value is invalid.

Implementations

impl NoisyFloat<f32, NumChecker>[src]

pub const fn unchecked_new(value: f32) -> Self[src]

A const constructor that does not check whether value is valid.

WARNING: This constructor does not panic even in debug mode. As always, it is the user’s responsibility to ensure value is valid. Until Rust supports panics in const functions, this constructor is necessary to create a NoisyFloat in a const setting.

pub const fn const_raw(self) -> f32[src]

A const function that returns the underlying float value.

impl NoisyFloat<f64, NumChecker>[src]

pub const fn unchecked_new(value: f64) -> Self[src]

A const constructor that does not check whether value is valid.

WARNING: This constructor does not panic even in debug mode. As always, it is the user’s responsibility to ensure value is valid. Until Rust supports panics in const functions, this constructor is necessary to create a NoisyFloat in a const setting.

pub const fn const_raw(self) -> f64[src]

A const function that returns the underlying float value.

impl NoisyFloat<f32, FiniteChecker>[src]

pub const fn unchecked_new(value: f32) -> Self[src]

A const constructor that does not check whether value is valid.

WARNING: This constructor does not panic even in debug mode. As always, it is the user’s responsibility to ensure value is valid. Until Rust supports panics in const functions, this constructor is necessary to create a NoisyFloat in a const setting.

pub const fn const_raw(self) -> f32[src]

A const function that returns the underlying float value.

impl NoisyFloat<f64, FiniteChecker>[src]

pub const fn unchecked_new(value: f64) -> Self[src]

A const constructor that does not check whether value is valid.

WARNING: This constructor does not panic even in debug mode. As always, it is the user’s responsibility to ensure value is valid. Until Rust supports panics in const functions, this constructor is necessary to create a NoisyFloat in a const setting.

pub const fn const_raw(self) -> f64[src]

A const function that returns the underlying float value.

impl<F: Float, C: FloatChecker<F>> NoisyFloat<F, C>[src]

pub fn new(value: F) -> Self[src]

Constructs a NoisyFloat with the given value.

Uses the FloatChecker to assert that the value is valid.

pub fn try_new(value: F) -> Option<Self>[src]

Tries to construct a NoisyFloat with the given value.

Returns None if the value is invalid.

pub fn borrowed(value: &F) -> &Self[src]

Converts the value in-place to a reference to a NoisyFloat.

Uses the FloatChecker to assert that the value is valid.

pub fn try_borrowed(value: &F) -> Option<&Self>[src]

Tries to convert the value in-place to a reference to a NoisyFloat.

Returns None if the value is invalid.

pub fn borrowed_mut(value: &mut F) -> &mut Self[src]

Converts the value in-place to a mutable reference to a NoisyFloat.

Uses the FloatChecker to assert that the value is valid.

pub fn try_borrowed_mut(value: &mut F) -> Option<&mut Self>[src]

Tries to convert the value in-place to a mutable reference to a NoisyFloat.

Returns None if the value is invalid.

pub fn from_f32(value: f32) -> Self[src]

Constructs a NoisyFloat with the given f32 value.

May panic not only by the FloatChecker but also by unwrapping the result of a NumCast invocation for type F, although the later should not occur in normal situations.

pub fn from_f64(value: f64) -> Self[src]

Constructs a NoisyFloat with the given f64 value.

May panic not only by the FloatChecker but also by unwrapping the result of a NumCast invocation for type F, although the later should not occur in normal situations.

pub fn raw(self) -> F[src]

Returns the underlying float value.

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

Compares and returns the minimum of two values.

This method exists to disambiguate between num_traits::Float.min and std::cmp::Ord.min.

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

Compares and returns the maximum of two values.

This method exists to disambiguate between num_traits::Float.max and std::cmp::Ord.max.

Trait Implementations

impl<'a, F: Float, C: FloatChecker<F>> Add<&'a F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the + operator.

impl<'a, F: Float, C: FloatChecker<F>> Add<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the + operator.

impl<F: Float, C: FloatChecker<F>> Add<F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the + operator.

impl<F: Float, C: FloatChecker<F>> Add<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the + operator.

impl<'a, F: Float + AddAssign, C: FloatChecker<F>> AddAssign<&'a F> for NoisyFloat<F, C>[src]

impl<'a, F: Float + AddAssign, C: FloatChecker<F>> AddAssign<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float + AddAssign, C: FloatChecker<F>> AddAssign<F> for NoisyFloat<F, C>[src]

impl<F: Float + AddAssign, C: FloatChecker<F>> AddAssign<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> AsRef<F> for NoisyFloat<F, C>[src]

impl<F: Float + Bounded, C: FloatChecker<F>> Bounded for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Clone for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Copy for NoisyFloat<F, C>[src]

impl<F: Float + Debug, C: FloatChecker<F>> Debug for NoisyFloat<F, C>[src]

impl<F: Float + Default, C: FloatChecker<F>> Default for NoisyFloat<F, C>[src]

impl<F: Float + Display, C: FloatChecker<F>> Display for NoisyFloat<F, C>[src]

impl<'a, F: Float, C: FloatChecker<F>> Div<&'a F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the / operator.

impl<'a, F: Float, C: FloatChecker<F>> Div<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the / operator.

impl<F: Float, C: FloatChecker<F>> Div<F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the / operator.

impl<F: Float, C: FloatChecker<F>> Div<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the / operator.

impl<'a, F: Float + DivAssign, C: FloatChecker<F>> DivAssign<&'a F> for NoisyFloat<F, C>[src]

impl<'a, F: Float + DivAssign, C: FloatChecker<F>> DivAssign<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float + DivAssign, C: FloatChecker<F>> DivAssign<F> for NoisyFloat<F, C>[src]

impl<F: Float + DivAssign, C: FloatChecker<F>> DivAssign<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Eq for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Float for NoisyFloat<F, C>[src]

impl<F: Float + FloatConst, C: FloatChecker<F>> FloatConst for NoisyFloat<F, C>[src]

impl<F: Float> From<NoisyFloat<F, FiniteChecker>> for NoisyFloat<F, NumChecker>[src]

impl<F: Float + FromPrimitive, C: FloatChecker<F>> FromPrimitive for NoisyFloat<F, C>[src]

impl<C: FloatChecker<f32>> Hash for NoisyFloat<f32, C>[src]

impl<C: FloatChecker<f64>> Hash for NoisyFloat<f64, C>[src]

impl<F: Float + LowerExp, C: FloatChecker<F>> LowerExp for NoisyFloat<F, C>[src]

impl<'a, F: Float, C: FloatChecker<F>> Mul<&'a F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the * operator.

impl<'a, F: Float, C: FloatChecker<F>> Mul<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the * operator.

impl<F: Float, C: FloatChecker<F>> Mul<F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the * operator.

impl<F: Float, C: FloatChecker<F>> Mul<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the * operator.

impl<'a, F: Float + MulAssign, C: FloatChecker<F>> MulAssign<&'a F> for NoisyFloat<F, C>[src]

impl<'a, F: Float + MulAssign, C: FloatChecker<F>> MulAssign<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float + MulAssign, C: FloatChecker<F>> MulAssign<F> for NoisyFloat<F, C>[src]

impl<F: Float + MulAssign, C: FloatChecker<F>> MulAssign<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Neg for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the - operator.

impl<'a, F: Float, C: FloatChecker<F>> Neg for &'a NoisyFloat<F, C>[src]

type Output = NoisyFloat<F, C>

The resulting type after applying the - operator.

impl<F: Float, C: FloatChecker<F>> Num for NoisyFloat<F, C>[src]

type FromStrRadixErr = F::FromStrRadixErr

impl<F: Float, C: FloatChecker<F>> NumCast for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> One for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Ord for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> PartialEq<F> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> PartialEq<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> PartialOrd<F> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> PartialOrd<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<'a, F: Float, C: FloatChecker<F>> Product<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Product<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<'a, F: Float, C: FloatChecker<F>> Rem<&'a F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the % operator.

impl<'a, F: Float, C: FloatChecker<F>> Rem<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the % operator.

impl<F: Float, C: FloatChecker<F>> Rem<F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the % operator.

impl<F: Float, C: FloatChecker<F>> Rem<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the % operator.

impl<'a, F: Float + RemAssign, C: FloatChecker<F>> RemAssign<&'a F> for NoisyFloat<F, C>[src]

impl<'a, F: Float + RemAssign, C: FloatChecker<F>> RemAssign<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float + RemAssign, C: FloatChecker<F>> RemAssign<F> for NoisyFloat<F, C>[src]

impl<F: Float + RemAssign, C: FloatChecker<F>> RemAssign<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float + Signed, C: FloatChecker<F>> Signed for NoisyFloat<F, C>[src]

impl<'a, F: Float, C: FloatChecker<F>> Sub<&'a F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the - operator.

impl<'a, F: Float, C: FloatChecker<F>> Sub<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the - operator.

impl<F: Float, C: FloatChecker<F>> Sub<F> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the - operator.

impl<F: Float, C: FloatChecker<F>> Sub<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

type Output = Self

The resulting type after applying the - operator.

impl<'a, F: Float + SubAssign, C: FloatChecker<F>> SubAssign<&'a F> for NoisyFloat<F, C>[src]

impl<'a, F: Float + SubAssign, C: FloatChecker<F>> SubAssign<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float + SubAssign, C: FloatChecker<F>> SubAssign<F> for NoisyFloat<F, C>[src]

impl<F: Float + SubAssign, C: FloatChecker<F>> SubAssign<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<'a, F: Float, C: FloatChecker<F>> Sum<&'a NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Sum<NoisyFloat<F, C>> for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> ToPrimitive for NoisyFloat<F, C>[src]

impl<C: FloatChecker<f32>> TryFrom<f32> for NoisyFloat<f32, C>[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<C: FloatChecker<f64>> TryFrom<f64> for NoisyFloat<f64, C>[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl<F: Float + UpperExp, C: FloatChecker<F>> UpperExp for NoisyFloat<F, C>[src]

impl<F: Float, C: FloatChecker<F>> Zero for NoisyFloat<F, C>[src]

Auto Trait Implementations

impl<F, C> RefUnwindSafe for NoisyFloat<F, C> where
    C: RefUnwindSafe,
    F: RefUnwindSafe

impl<F, C> Send for NoisyFloat<F, C> where
    C: Send,
    F: Send

impl<F, C> Sync for NoisyFloat<F, C> where
    C: Sync,
    F: Sync

impl<F, C> Unpin for NoisyFloat<F, C> where
    C: Unpin,
    F: Unpin

impl<F, C> UnwindSafe for NoisyFloat<F, C> where
    C: UnwindSafe,
    F: 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> NumAssignRef for T where
    T: NumAssign + for<'r> NumAssignOps<&'r T>, 
[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> NumRef for T where
    T: Num + for<'r> NumOps<&'r T, T>, 
[src]

impl<T> Real for T where
    T: Float
[src]

impl<T, Base> RefNum<Base> for T where
    T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>, 
[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.