Enum MinMaxResult

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: Self) -> Option<(T, T)>

into_option creates an Option of type (T, T). The returned Option has variant None if and only if the MinMaxResult has variant NoElements. Otherwise Some((x, y)) is returned where x <= y. If the MinMaxResult has variant OneElement(x), performing this operation will make one clone of x.

Examples

use itertools::MinMaxResult::{self, NoElements, OneElement, MinMax};

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)));

impl<T> Any for MinMaxResult<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for MinMaxResult<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for MinMaxResult<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for MinMaxResult<T>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> Freeze for MinMaxResult<T>

impl<T> From for MinMaxResult<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for MinMaxResult<T>

impl<T> Send for MinMaxResult<T>

impl<T> StructuralPartialEq for MinMaxResult<T>

impl<T> Sync for MinMaxResult<T>

impl<T> ToOwned for MinMaxResult<T>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> Unpin for MinMaxResult<T>

impl<T> UnsafeUnpin for MinMaxResult<T>

impl<T> UnwindSafe for MinMaxResult<T>

impl<T, U> Into for MinMaxResult<T>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for MinMaxResult<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for MinMaxResult<T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<T: $crate::clone::Clone> Clone for MinMaxResult<T>

fn clone(self: &Self) -> MinMaxResult<T>

impl<T: $crate::cmp::Eq> Eq for MinMaxResult<T>

impl<T: $crate::cmp::PartialEq> PartialEq for MinMaxResult<T>

fn eq(self: &Self, other: &MinMaxResult<T>) -> bool

impl<T: $crate::fmt::Debug> Debug for MinMaxResult<T>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T: $crate::marker::Copy> Copy for MinMaxResult<T>