Skip to content

Commit 9e1e989

Browse files
committed
Document unsafety in partial_insertion_sort
We already implicitly (or explicitly??) do the bound checking for the indexing.
1 parent 9e8b42c commit 9e1e989

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libcore/slice/sort.rs

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ where
131131
let mut i = 1;
132132

133133
for _ in 0..MAX_STEPS {
134+
// SAFETY: We already explicitly done the bound checking with `i<len`
135+
// All our indexing following that is only in the range {0 <= index < len}
134136
unsafe {
135137
// Find the next pair of adjacent out-of-order elements.
136138
while i < len && !is_less(v.get_unchecked(i), v.get_unchecked(i - 1)) {

0 commit comments

Comments
 (0)