Rename method to assert_len
This commit is contained in:
parent
eb63168e00
commit
f055b0bb08
8 changed files with 57 additions and 57 deletions
|
@ -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)
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue