Skip to content

Commit 02ea82d

Browse files
committed
Auto merge of #38144 - clarcharr:redundant, r=alexcrichton
Remove redundant assertion near is_char_boundary Follow-up from #38056. `is_char_boundary` already checks for `idx <= len`, so, an extra assertion is redundant.
2 parents 3fef221 + 4dd590a commit 02ea82d

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

src/libcollections/string.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,6 @@ impl String {
11291129
#[inline]
11301130
#[stable(feature = "rust1", since = "1.0.0")]
11311131
pub fn insert(&mut self, idx: usize, ch: char) {
1132-
let len = self.len();
1133-
assert!(idx <= len);
11341132
assert!(self.is_char_boundary(idx));
11351133
let mut bits = [0; 4];
11361134
let bits = ch.encode_utf8(&mut bits).as_bytes();
@@ -1184,7 +1182,6 @@ impl String {
11841182
reason = "recent addition",
11851183
issue = "35553")]
11861184
pub fn insert_str(&mut self, idx: usize, string: &str) {
1187-
assert!(idx <= self.len());
11881185
assert!(self.is_char_boundary(idx));
11891186

11901187
unsafe {
@@ -1288,7 +1285,6 @@ impl String {
12881285
#[unstable(feature = "string_split_off", issue = "38080")]
12891286
pub fn split_off(&mut self, mid: usize) -> String {
12901287
assert!(self.is_char_boundary(mid));
1291-
assert!(mid <= self.len());
12921288
let other = self.vec.split_off(mid);
12931289
unsafe { String::from_utf8_unchecked(other) }
12941290
}

0 commit comments

Comments
 (0)