about summary refs log tree commit diff
path: root/library/alloc/src/string.rs
diff options
context:
space:
mode:
authordylni <46035563+dylni@users.noreply.github.com>2020-09-18 12:17:51 -0400
committerdylni <46035563+dylni@users.noreply.github.com>2020-09-18 12:17:51 -0400
commit1ff7da6551a7cdf6ace2a9d00e92bbab550334ee (patch)
tree83dfb35cedd5a32e6044bfb12c03d38a907b5b00 /library/alloc/src/string.rs
parent2c69266c0697b0c0b34abea62cba1a1d3c59c90c (diff)
downloadrust-1ff7da6551a7cdf6ace2a9d00e92bbab550334ee.tar.gz
rust-1ff7da6551a7cdf6ace2a9d00e92bbab550334ee.zip
Move `slice::check_range` to `RangeBounds`
Diffstat (limited to 'library/alloc/src/string.rs')
-rw-r--r--library/alloc/src/string.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 2b0ce5ede56..26124e30111 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -49,7 +49,6 @@ 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};
@@ -1507,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 } = slice::check_range(self.len(), range);
+        let Range { start, end } = range.for_length(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: `check_range` and `is_char_boundary` do the appropriate bounds checks.
+        // SAFETY: `for_length` 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 }