Enum MinMaxResult
pub enum MinMaxResult<T>
MinMaxResult is an enum returned by minmax.
See .minmax() for more detail.
Variants
-
NoElements Empty iterator
-
OneElement(T) Iterator with one element, so the minimum and maximum are the same
-
MinMax(T, T) More than one element in the iterator, the first element is not larger than the second
Implementations
impl<T: Clone> MinMaxResult<T>
fn into_option(self) -> Option<(T, T)>into_optioncreates anOptionof type(T, T). The returnedOptionhas variantNoneif and only if theMinMaxResulthas variantNoElements. OtherwiseSome((x, y))is returned wherex <= y. If theMinMaxResulthas variantOneElement(x), performing this operation will make one clone ofx.Examples
use itertools::MinMaxResult::{self, MinMax, NoElements, OneElement}; let r: MinMaxResult<i32> = NoElements; assert_eq!(r.into_option(), None); let r = OneElement(1); assert_eq!(r.into_option(), Some((1, 1))); let r = MinMax(1, 2); assert_eq!(r.into_option(), Some((1, 2)));
Trait Implementations
impl<T: Clone> Clone for MinMaxResult<T>
fn clone(&self) -> Self
impl<T: Copy> Copy for MinMaxResult<T>
impl<T: Debug> Debug for MinMaxResult<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: Eq> Eq for MinMaxResult<T>
impl<T: PartialEq> PartialEq for MinMaxResult<T>
fn eq(&self, other: &Self) -> bool