1
1
use std:: cmp:: Ordering ;
2
2
3
3
/// Implementation guts for `min_set`, `min_set_by`, and `min_set_by_key`.
4
- pub fn min_set_impl < I , K , F , Compare > ( mut it : I ,
5
- mut key_for : F ,
6
- mut compare : Compare ) -> Vec < I :: Item >
7
- where I : Iterator ,
8
- F : FnMut ( & I :: Item ) -> K ,
9
- Compare : FnMut ( & I :: Item , & I :: Item , & K , & K ) -> Ordering ,
4
+ pub fn min_set_impl < I , K , F , Compare > (
5
+ mut it : I ,
6
+ mut key_for : F ,
7
+ mut compare : Compare ,
8
+ ) -> Vec < I :: Item >
9
+ where
10
+ I : Iterator ,
11
+ F : FnMut ( & I :: Item ) -> K ,
12
+ Compare : FnMut ( & I :: Item , & I :: Item , & K , & K ) -> Ordering ,
10
13
{
11
14
match it. next ( ) {
12
15
None => Vec :: new ( ) ,
@@ -20,29 +23,26 @@ pub fn min_set_impl<I, K, F, Compare>(mut it: I,
20
23
result. clear ( ) ;
21
24
result. push ( element) ;
22
25
current_key = key;
23
- } ,
26
+ }
24
27
Ordering :: Equal => {
25
28
result. push ( element) ;
26
- } ,
27
- Ordering :: Greater => {
28
- } ,
29
+ }
30
+ Ordering :: Greater => { }
29
31
}
30
32
} ) ;
31
33
result
32
34
}
33
35
}
34
-
35
36
}
36
37
37
38
/// Implementation guts for `ax_set`, `max_set_by`, and `max_set_by_key`.
38
- pub fn max_set_impl < I , K , F , Compare > ( it : I ,
39
- key_for : F ,
40
- mut compare : Compare ) -> Vec < I :: Item >
41
- where I : Iterator ,
42
- F : FnMut ( & I :: Item ) -> K ,
43
- Compare : FnMut ( & I :: Item , & I :: Item , & K , & K ) -> Ordering ,
39
+ pub fn max_set_impl < I , K , F , Compare > ( it : I , key_for : F , mut compare : Compare ) -> Vec < I :: Item >
40
+ where
41
+ I : Iterator ,
42
+ F : FnMut ( & I :: Item ) -> K ,
43
+ Compare : FnMut ( & I :: Item , & I :: Item , & K , & K ) -> Ordering ,
44
44
{
45
- min_set_impl ( it, key_for, |it1, it2, key1, key2| compare ( it2, it1, key2, key1) )
45
+ min_set_impl ( it, key_for, |it1, it2, key1, key2| {
46
+ compare ( it2, it1, key2, key1)
47
+ } )
46
48
}
47
-
48
-
0 commit comments