We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8cc6998 commit 52f9762Copy full SHA for 52f9762
src/libcore/slice/mod.rs
@@ -2694,6 +2694,15 @@ impl<T> [T] {
2694
2695
while left != right {
2696
let mid = left + (right - left) / 2;
2697
+ // SAFETY:
2698
+ // When left < right, left <= mid < right.
2699
+ // Therefore left always increases and right always decreases,
2700
+ // and eigher of them is selected.
2701
+ // In both cases left <= right is satisfied.
2702
+ // Therefore if left < right in a step,
2703
+ // left <= right is satisfied in the next step.
2704
+ // Therefore as long as left != right, 0 <= left < right <= len is satisfied
2705
+ // and if this case 0 <= mid < len is satisfied too.
2706
let value = unsafe { self.get_unchecked(mid) };
2707
if pred(value) {
2708
left = mid + 1;
0 commit comments