[][src]Trait conv::errors::Saturate

pub trait Saturate {
    type Output;
    fn saturate(self) -> Self::Output;
}

Saturates a Result.

Associated Types

type Output

The result of saturating.

Loading content...

Required methods

fn saturate(self) -> Self::Output

Replaces an overflow error with a saturated value.

Unlike unwrap_or_saturate, this method can be used in cases where the Result error type can encode failures other than overflow and underflow. For example, you cannot saturate a float-to-integer conversion using unwrap_or_saturate as the error might be NotANumber, which doesn't have a meaningful saturation "direction".

The output of this method will be a Result where the error type does not contain overflow conditions. What conditions remain must still be dealt with in some fashion.

Loading content...

Implementations on Foreign Types

impl<T, U> Saturate for Result<T, FloatError<U>> where
    T: Saturated
[src]

type Output = Result<T, Unrepresentable<U>>

impl<T, U> Saturate for Result<T, RangeError<U>> where
    T: Saturated
[src]

type Output = Result<T, NoError>

impl<T> Saturate for Result<T, RangeErrorKind> where
    T: Saturated
[src]

type Output = Result<T, NoError>

Loading content...

Implementors

Loading content...