pub enum Approximation<T, E> {
Exact(T),
Inexact(T, E),
}Expand description
Represent an calculation result with a possible error.
Variants§
Exact(T)
The result is exact, contains the result value
Inexact(T, E)
The result is inexact, contains the result value and error
Implementations§
Source§impl<T, E> Approximation<T, E>
impl<T, E> Approximation<T, E>
Sourcepub fn value_with_exact(self) -> (T, bool)
pub fn value_with_exact(self) -> (T, bool)
The value together with whether the computation was exact.
The boolean is true for an exact result and false for an inexact one; the error E is
discarded (use error when the error magnitude matters). Handy for the
“value + exactness flag” pattern (e.g. MPFR’s exact flag, which a Ziv closure needs to
report a zero radius for an exactly-representable result).
Sourcepub fn error(self) -> Option<E>
pub fn error(self) -> Option<E>
Return the error if the result is inexact, None if it is exact.
Sourcepub const fn error_ref(&self) -> Option<&E>
pub const fn error_ref(&self) -> Option<&E>
Borrow the error if the result is inexact, None if it is exact.
Sourcepub fn map<U, F>(self, f: F) -> Approximation<U, E>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> Approximation<U, E>where
F: FnOnce(T) -> U,
Map the result value to a new type, preserving the error (if any).
Sourcepub fn and_then<U, F>(self, f: F) -> Approximation<U, E>where
F: FnOnce(T) -> Approximation<U, E>,
pub fn and_then<U, F>(self, f: F) -> Approximation<U, E>where
F: FnOnce(T) -> Approximation<U, E>,
Chain a fallible mapping that itself returns an Approximation, combining the
errors: an inexact input or an inexact result both yield an inexact result.
Trait Implementations§
Source§impl<T, E> Clone for Approximation<T, E>
impl<T, E> Clone for Approximation<T, E>
Source§fn clone(&self) -> Approximation<T, E>
fn clone(&self) -> Approximation<T, E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<T, E> Copy for Approximation<T, E>
Source§impl<T, E> Debug for Approximation<T, E>
impl<T, E> Debug for Approximation<T, E>
impl<T, E> Eq for Approximation<T, E>
Source§impl<T, E> PartialEq for Approximation<T, E>
impl<T, E> PartialEq for Approximation<T, E>
impl<T, E> StructuralPartialEq for Approximation<T, E>
Auto Trait Implementations§
impl<T, E> Freeze for Approximation<T, E>
impl<T, E> RefUnwindSafe for Approximation<T, E>where
T: RefUnwindSafe,
E: RefUnwindSafe,
impl<T, E> Send for Approximation<T, E>
impl<T, E> Sync for Approximation<T, E>
impl<T, E> Unpin for Approximation<T, E>
impl<T, E> UnsafeUnpin for Approximation<T, E>where
T: UnsafeUnpin,
E: UnsafeUnpin,
impl<T, E> UnwindSafe for Approximation<T, E>where
T: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.