Rename Range::ensure_subset_of
to slice::range
This commit is contained in:
parent
f6111a256e
commit
5d519eaa6e
8 changed files with 115 additions and 112 deletions
|
@ -1063,7 +1063,7 @@ impl<T> VecDeque<T> {
|
|||
where
|
||||
R: RangeBounds<usize>,
|
||||
{
|
||||
let Range { start, end } = Range::ensure_subset_of(range, ..self.len());
|
||||
let Range { start, end } = slice::range(range, ..self.len());
|
||||
let tail = self.wrap_add(self.tail, start);
|
||||
let head = self.wrap_add(self.tail, end);
|
||||
(tail, head)
|
||||
|
|
|
@ -115,7 +115,6 @@
|
|||
#![feature(or_patterns)]
|
||||
#![feature(pattern)]
|
||||
#![feature(ptr_internals)]
|
||||
#![feature(range_ensure_subset_of)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(receiver_trait)]
|
||||
#![cfg_attr(bootstrap, feature(min_const_generics))]
|
||||
|
@ -123,6 +122,7 @@
|
|||
#![feature(set_ptr_value)]
|
||||
#![feature(slice_ptr_get)]
|
||||
#![feature(slice_ptr_len)]
|
||||
#![feature(slice_range)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(str_internals)]
|
||||
#![feature(trusted_len)]
|
||||
|
|
|
@ -92,6 +92,8 @@ use crate::borrow::ToOwned;
|
|||
use crate::boxed::Box;
|
||||
use crate::vec::Vec;
|
||||
|
||||
#[unstable(feature = "slice_range", issue = "76393")]
|
||||
pub use core::slice::range;
|
||||
#[unstable(feature = "array_chunks", issue = "74985")]
|
||||
pub use core::slice::ArrayChunks;
|
||||
#[unstable(feature = "array_chunks", issue = "74985")]
|
||||
|
|
|
@ -49,6 +49,7 @@ use core::iter::{FromIterator, FusedIterator};
|
|||
use core::ops::Bound::{Excluded, Included, Unbounded};
|
||||
use core::ops::{self, Add, AddAssign, Index, IndexMut, Range, RangeBounds};
|
||||
use core::ptr;
|
||||
use core::slice;
|
||||
use core::str::{lossy, pattern::Pattern};
|
||||
|
||||
use crate::borrow::{Cow, ToOwned};
|
||||
|
@ -1510,14 +1511,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::ensure_subset_of(range, ..self.len());
|
||||
let Range { start, end } = slice::range(range, ..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: `ensure_subset_of` and `is_char_boundary` do the appropriate bounds checks.
|
||||
// SAFETY: `slice::range` 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 }
|
||||
|
|
|
@ -1650,7 +1650,7 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||
// the hole, and the vector length is restored to the new length.
|
||||
//
|
||||
let len = self.len();
|
||||
let Range { start, end } = Range::ensure_subset_of(range, ..len);
|
||||
let Range { start, end } = slice::range(range, ..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