1
Fork 0

Auto merge of #76885 - dylni:move-slice-check-range-to-range-bounds, r=KodrAus

Move `slice::check_range` to `RangeBounds`

Since this method doesn't take a slice anymore (#76662), it makes more sense to define it on `RangeBounds`.

Questions:
- Should the new method be `assert_len` or `assert_length`?
This commit is contained in:
bors 2020-10-18 18:50:43 +00:00
commit 187b8771dc
10 changed files with 112 additions and 101 deletions

View file

@ -1314,7 +1314,7 @@ impl<T> Vec<T> {
// the hole, and the vector length is restored to the new length.
//
let len = self.len();
let Range { start, end } = slice::check_range(len, range);
let Range { start, end } = range.assert_len(len);
unsafe {
// set self.vec length's to start, to be safe in case Drain is leaked