@@ -2956,7 +2956,7 @@ pub trait Itertools: Iterator {
29562956 Self :: Item : Ord ,
29572957 {
29582958 // The stdlib heap has optimised handling of "holes", which is not included in our heap implementation in k_smallest_general.
2959- // While the difference is unlikely to have practical impact unless `T ` is very large, this method uses the stdlib structure
2959+ // While the difference is unlikely to have practical impact unless `Self::Item ` is very large, this method uses the stdlib structure
29602960 // to maintain performance compared to previous versions of the crate.
29612961 use alloc:: collections:: BinaryHeap ;
29622962
@@ -3011,7 +3011,7 @@ pub trait Itertools: Iterator {
30113011 /// Sort the k largest elements into a new iterator, in descending order.
30123012 /// Semantically equivalent to `k_smallest` with a reversed `Ord`
30133013 /// However, this is implemented by way of a custom binary heap
3014- /// which does not have the same performance characteristics for very large `T `
3014+ /// which does not have the same performance characteristics for very large `Self::Item `
30153015 /// ```
30163016 /// use itertools::Itertools;
30173017 ///
@@ -3030,7 +3030,7 @@ pub trait Itertools: Iterator {
30303030 Self : Sized ,
30313031 Self :: Item : Ord ,
30323032 {
3033- self . k_smallest_by ( k, k_smallest :: reverse_cmp ( Self :: Item :: cmp) )
3033+ self . k_largest_by ( k, Self :: Item :: cmp)
30343034 }
30353035
30363036 /// Sort the k largest elements into a new iterator using the provided comparison.
@@ -3041,7 +3041,7 @@ pub trait Itertools: Iterator {
30413041 Self : Sized ,
30423042 F : Fn ( & Self :: Item , & Self :: Item ) -> Ordering ,
30433043 {
3044- self . k_smallest_by ( k, k_smallest :: reverse_cmp ( cmp) )
3044+ self . k_smallest_by ( k, move |a , b| cmp ( b , a ) )
30453045 }
30463046
30473047 /// Return the elements producing the k largest outputs of the provided function
0 commit comments