Trait option_operations::min_max::OptionMinMax

source ·
pub trait OptionMinMax<Other, Inner = Other> {
    // Required methods
    fn opt_min(self, other: Other) -> Option<Inner>;
    fn opt_max(self, other: Other) -> Option<Inner>;
}
Expand description

Trait for values and Options that can be compared to get the minimum or maximum.

Implementing this type leads to the following auto-implementations:

  • OptionMinMax<Option<InnerRhs>> for T.
  • OptionMinMax<Rhs> for Option<T>.
  • OptionMinMax<Option<InnerRhs>> for Option<T>.
  • … and some variants with references.

This trait is auto-implemented for OptionOperations types implementing OptionOrd<Rhs>.

Required Methods§

source

fn opt_min(self, other: Other) -> Option<Inner>

Compares and returns the minimum of two values.

Returns None if they can’t be compared, e.g. if at most one argument is None.

source

fn opt_max(self, other: Other) -> Option<Inner>

Compares and returns the maximum of two values.

Returns None if they can’t be compared, e.g. if at most one argument is None.

Implementations on Foreign Types§

source§

impl<T> OptionMinMax<Option<T>, T> for Option<T>
where T: for<'a> OptionOrd<&'a T, T>,

source§

fn opt_min(self, other: Option<T>) -> Option<T>

source§

fn opt_max(self, other: Option<T>) -> Option<T>

source§

impl<T> OptionMinMax<T> for Option<T>
where T: for<'a> OptionOrd<&'a T, T>,

source§

fn opt_min(self, other: T) -> Option<T>

source§

fn opt_max(self, other: T) -> Option<T>

Implementors§

source§

impl<T> OptionMinMax<Option<T>, T> for T
where T: for<'a> OptionOrd<&'a T, T>,

source§

impl<T> OptionMinMax<T> for T
where T: for<'a> OptionOrd<&'a T, T>,