@@ -607,15 +607,15 @@ fn test_count() {
607
607
}
608
608
609
609
#[ test]
610
- fn test_max_by ( ) {
610
+ fn test_max_by_key ( ) {
611
611
let xs: & [ isize ] = & [ -3 , 0 , 1 , 5 , -10 ] ;
612
- assert_eq ! ( * xs. iter( ) . max_by ( |x| x. abs( ) ) . unwrap( ) , -10 ) ;
612
+ assert_eq ! ( * xs. iter( ) . max_by_key ( |x| x. abs( ) ) . unwrap( ) , -10 ) ;
613
613
}
614
614
615
615
#[ test]
616
- fn test_min_by ( ) {
616
+ fn test_min_by_key ( ) {
617
617
let xs: & [ isize ] = & [ -3 , 0 , 1 , 5 , -10 ] ;
618
- assert_eq ! ( * xs. iter( ) . min_by ( |x| x. abs( ) ) . unwrap( ) , 0 ) ;
618
+ assert_eq ! ( * xs. iter( ) . min_by_key ( |x| x. abs( ) ) . unwrap( ) , 0 ) ;
619
619
}
620
620
621
621
#[ test]
@@ -961,18 +961,18 @@ fn bench_multiple_take(b: &mut Bencher) {
961
961
fn scatter ( x : i32 ) -> i32 { ( x * 31 ) % 127 }
962
962
963
963
#[ bench]
964
- fn bench_max_by ( b : & mut Bencher ) {
964
+ fn bench_max_by_key ( b : & mut Bencher ) {
965
965
b. iter ( || {
966
966
let it = 0 ..100 ;
967
- it. max_by ( |& x| scatter ( x) )
967
+ it. max_by_key ( |& x| scatter ( x) )
968
968
} )
969
969
}
970
970
971
971
// http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/
972
972
#[ bench]
973
- fn bench_max_by2 ( b : & mut Bencher ) {
973
+ fn bench_max_by_key2 ( b : & mut Bencher ) {
974
974
fn max_index_iter ( array : & [ i32 ] ) -> usize {
975
- array. iter ( ) . enumerate ( ) . max_by ( |& ( _, item) | item) . unwrap ( ) . 0
975
+ array. iter ( ) . enumerate ( ) . max_by_key ( |& ( _, item) | item) . unwrap ( ) . 0
976
976
}
977
977
978
978
let mut data = vec ! [ 0i32 ; 1638 ] ;
0 commit comments