@@ -4071,6 +4071,23 @@ pub trait Itertools: Iterator {
40714071 /// use itertools::Itertools;
40724072 /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
40734073 ///
4074+ /// let a: [i32; 0] = [];
4075+ /// assert_eq!(a.iter().minmax(), NoElements);
4076+ ///
4077+ /// let a = [1];
4078+ /// assert_eq!(a.iter().minmax(), OneElement(&1));
4079+ ///
4080+ /// let a = [1, 2, 3, 4, 5];
4081+ /// assert_eq!(a.iter().minmax(), MinMax(&1, &5));
4082+ ///
4083+ /// let a = [1, 1, 1, 1];
4084+ /// assert_eq!(a.iter().minmax(), MinMax(&1, &1));
4085+ /// ```
4086+ ///
4087+ /// ```
4088+ /// use itertools::Itertools;
4089+ /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
4090+ ///
40744091 /// let a: [(i32, char); 0] = [];
40754092 /// assert_eq!(a.iter().minmax(), NoElements);
40764093 ///
@@ -4107,6 +4124,7 @@ pub trait Itertools: Iterator {
41074124 /// if a key is NaN.
41084125 ///
41094126 /// # Examples
4127+ ///
41104128 /// ```
41114129 /// use itertools::Itertools;
41124130 /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
@@ -4149,19 +4167,19 @@ pub trait Itertools: Iterator {
41494167 /// use itertools::Itertools;
41504168 /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
41514169 ///
4152- /// let abs_cmp = |x: &&(i32, char), y: &&(i32, char)| x.0.cmp(&y.0);
4170+ /// let first_item_cmp = |x: &&(i32, char), y: &&(i32, char)| x.0.cmp(&y.0);
41534171 ///
41544172 /// let a: [(i32, char); 0] = [];
4155- /// assert_eq!(a.iter().minmax_by(abs_cmp ), NoElements);
4173+ /// assert_eq!(a.iter().minmax_by(first_item_cmp ), NoElements);
41564174 ///
41574175 /// let a = [(1, 'a')];
4158- /// assert_eq!(a.iter().minmax_by(abs_cmp ), OneElement(&(1, 'a')));
4176+ /// assert_eq!(a.iter().minmax_by(first_item_cmp ), OneElement(&(1, 'a')));
41594177 ///
41604178 /// let a = [(0, 'a'), (1, 'b')];
4161- /// assert_eq!(a.iter().minmax_by(abs_cmp ), MinMax(&(0, 'a'), &(1, 'b')));
4179+ /// assert_eq!(a.iter().minmax_by(first_item_cmp ), MinMax(&(0, 'a'), &(1, 'b')));
41624180 ///
41634181 /// let a = [(1, 'a'), (1, 'b'), (1, 'c')];
4164- /// assert_eq!(a.iter().minmax_by(abs_cmp ), MinMax(&(1, 'a'), &(1, 'c')));
4182+ /// assert_eq!(a.iter().minmax_by(first_item_cmp ), MinMax(&(1, 'a'), &(1, 'c')));
41654183 /// ```
41664184 fn minmax_by < F > ( self , mut compare : F ) -> MinMaxResult < Self :: Item >
41674185 where
0 commit comments