Document unsafety in partial_insertion_sort

We already implicitly (or explicitly??) do the bound checking for the indexing.
This commit is contained in:
Hanif Bin Ariffin 2020-04-25 19:46:53 -04:00
parent 9e8b42c02b
commit 9e1e989f7c

View File

@ -131,6 +131,8 @@ where
let mut i = 1;
for _ in 0..MAX_STEPS {
// SAFETY: We already explicitly done the bound checking with `i<len`
// All our indexing following that is only in the range {0 <= index < len}
unsafe {
// Find the next pair of adjacent out-of-order elements.
while i < len && !is_less(v.get_unchecked(i), v.get_unchecked(i - 1)) {