k_smollest: Add debug_assert for invariant
@@ -7,6 +7,7 @@ pub(crate) fn k_smallest<T: Ord, I: Iterator<Item = T>>(mut iter: I, k: usize) -
let mut heap = iter.by_ref().take(k).collect::<BinaryHeap<_>>();
for i in iter {
+ debug_assert_eq!(heap.len(), k);
// Guaranteed not-None, since we keep exactly k>0 elements in the heap.
let mut lorgest = heap.peek_mut().unwrap();
if *lorgest > i { *lorgest = i; }
