1
Fork 0

Rename method to assert_len

This commit is contained in:
dylni 2020-09-18 13:55:03 -04:00
parent eb63168e00
commit f055b0bb08
8 changed files with 57 additions and 57 deletions

View file

@ -1089,7 +1089,7 @@ impl<T> VecDeque<T> {
where
R: RangeBounds<usize>,
{
let Range { start, end } = range.for_length(self.len());
let Range { start, end } = range.assert_len(self.len());
let tail = self.wrap_add(self.tail, start);
let head = self.wrap_add(self.tail, end);
(tail, head)

View file

@ -116,7 +116,7 @@
#![feature(or_patterns)]
#![feature(pattern)]
#![feature(ptr_internals)]
#![feature(range_bounds_for_length)]
#![feature(range_bounds_assert_len)]
#![feature(raw_ref_op)]
#![feature(rustc_attrs)]
#![feature(receiver_trait)]

View file

@ -1506,14 +1506,14 @@ impl String {
// of the vector version. The data is just plain bytes.
// Because the range removal happens in Drop, if the Drain iterator is leaked,
// the removal will not happen.
let Range { start, end } = range.for_length(self.len());
let Range { start, end } = range.assert_len(self.len());
assert!(self.is_char_boundary(start));
assert!(self.is_char_boundary(end));
// Take out two simultaneous borrows. The &mut String won't be accessed
// until iteration is over, in Drop.
let self_ptr = self as *mut _;
// SAFETY: `for_length` and `is_char_boundary` do the appropriate bounds checks.
// SAFETY: `assert_len` and `is_char_boundary` do the appropriate bounds checks.
let chars_iter = unsafe { self.get_unchecked(start..end) }.chars();
Drain { start, end, iter: chars_iter, string: self_ptr }

View file

@ -1312,7 +1312,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 } = range.for_length(len);
let Range { start, end } = range.assert_len(len);
unsafe {
// set self.vec length's to start, to be safe in case Drain is leaked