We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 58c0362 commit 7e0ff8bCopy full SHA for 7e0ff8b
src/k_smallest.rs
@@ -152,6 +152,10 @@ where
152
let (left_idx, right_idx) = children_of(origin);
153
let (left_item, right_item) = (self.get(left_idx), self.get(right_idx));
154
155
+ if left_item.is_none() { // the left is the earlier child, so if it doesn't exist there's nothing to swap with
156
+ return;
157
+ }
158
+
159
let cmp = self
160
.compare(left_item, right_item)
161
.unwrap_or(Ordering::Greater); // The right item may not exist, so default to picking the left, i.e. lower
0 commit comments