@@ -2956,7 +2956,7 @@ pub trait Itertools: Iterator {
2956
2956
Self :: Item : Ord ,
2957
2957
{
2958
2958
// 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
2960
2960
// to maintain performance compared to previous versions of the crate.
2961
2961
use alloc:: collections:: BinaryHeap ;
2962
2962
@@ -3011,7 +3011,7 @@ pub trait Itertools: Iterator {
3011
3011
/// Sort the k largest elements into a new iterator, in descending order.
3012
3012
/// Semantically equivalent to `k_smallest` with a reversed `Ord`
3013
3013
/// 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 `
3015
3015
/// ```
3016
3016
/// use itertools::Itertools;
3017
3017
///
@@ -3030,7 +3030,7 @@ pub trait Itertools: Iterator {
3030
3030
Self : Sized ,
3031
3031
Self :: Item : Ord ,
3032
3032
{
3033
- self . k_smallest_by ( k, k_smallest :: reverse_cmp ( Self :: Item :: cmp) )
3033
+ self . k_largest_by ( k, Self :: Item :: cmp)
3034
3034
}
3035
3035
3036
3036
/// Sort the k largest elements into a new iterator using the provided comparison.
@@ -3041,7 +3041,7 @@ pub trait Itertools: Iterator {
3041
3041
Self : Sized ,
3042
3042
F : Fn ( & Self :: Item , & Self :: Item ) -> Ordering ,
3043
3043
{
3044
- self . k_smallest_by ( k, k_smallest :: reverse_cmp ( cmp) )
3044
+ self . k_smallest_by ( k, move |a , b| cmp ( b , a ) )
3045
3045
}
3046
3046
3047
3047
/// Return the elements producing the k largest outputs of the provided function
0 commit comments