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_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, 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) -> MinMaxResult<T>

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: &MinMaxResult<T>) -> bool

impl<T: PartialEq> StructuralPartialEq for MinMaxResult<T>

Auto Trait Implementations

impl<T> Freeze for MinMaxResult<T> where T: Freeze + Freeze + Freeze,

impl<T> RefUnwindSafe for MinMaxResult<T> where T: RefUnwindSafe + RefUnwindSafe + RefUnwindSafe,

impl<T> Send for MinMaxResult<T> where T: Send + Send + Send,

impl<T> Sync for MinMaxResult<T> where T: Sync + Sync + Sync,

impl<T> Unpin for MinMaxResult<T> where T: Unpin + Unpin + Unpin,

impl<T> UnsafeUnpin for MinMaxResult<T> where T: UnsafeUnpin + UnsafeUnpin + UnsafeUnpin,

impl<T> UnwindSafe for MinMaxResult<T> where T: UnwindSafe + UnwindSafe + UnwindSafe,

Blanket Implementations

impl<T> Any for MinMaxResult<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for MinMaxResult<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for MinMaxResult<T> where T: ?Sized,

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

impl<T> CloneToUninit for MinMaxResult<T> where T: Clone,

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

impl<T> From<T> for MinMaxResult<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> IntoEither for MinMaxResult<T>

impl<T> ToOwned for MinMaxResult<T> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for MinMaxResult<T> where U: From<T>,

fn into(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<U> for MinMaxResult<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for MinMaxResult<T> where U: TryFrom<T>,

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