Skip to content

Commit d292fa0

Browse files
committed
k_smallest: Document the equivalence with self.sorted().take(k)
Consistency with `Iterator::take` is the rationale for returning less than `k` elements when the input is too short.
1 parent b0443e0 commit d292fa0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,9 @@ pub trait Itertools : Iterator {
22982298
/// The sorted iterator, if directly collected to a `Vec`, is converted
22992299
/// without any extra copying or allocation cost.
23002300
///
2301+
/// **Note:** This is functionally-equivalent to `self.sorted().take(k)`
2302+
/// but much more efficient.
2303+
///
23012304
/// ```
23022305
/// use itertools::Itertools;
23032306
///

0 commit comments

Comments
 (0)