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>2021-01-17 23:12:29 -0500
committerdylni <46035563+dylni@users.noreply.github.com>2021-02-12 22:01:04 -0500
commit9d29793614cc810fb8febf7f1a2e0202f3919bb6 (patch)
treebf124824063aead8e27099ec4144deb5facfa88e /library/alloc/src/string.rs
parent3f5aee2d5241139d808f4fdece0026603489afd1 (diff)
Improve design of `assert_len`
Diffstat (limited to 'library/alloc/src/string.rs')
-rw-r--r--library/alloc/src/string.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 3218b3535c9..3ab5ca4f566 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -1510,14 +1510,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.assert_len(self.len());
+        let Range { start, end } = range.ensure_subset_of(..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: `assert_len` and `is_char_boundary` do the appropriate bounds checks.
+        // SAFETY: `ensure_subset_of` 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 }