Skip to content

Commit 8f11a9e

Browse files
committed
Auto merge of #30677 - diwic:master, r=bluss
Obviously we can't remove the character one past the end of the String. And we can't today either - we'll just panic at char_at() instead - but if we're going to keep that assertion, we should at least have a correct assertion.
2 parents cae9267 + 8b398ed commit 8f11a9e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcollections/string.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,8 @@ impl String {
10291029
///
10301030
/// # Panics
10311031
///
1032-
/// Panics if `idx` is larger than the `String`'s length, or if it does not
1033-
/// lie on a [`char`] boundary.
1032+
/// Panics if `idx` is larger than or equal to the `String`'s length,
1033+
/// or if it does not lie on a [`char`] boundary.
10341034
///
10351035
/// [`char`]: ../primitive.char.html
10361036
///
@@ -1049,7 +1049,7 @@ impl String {
10491049
#[stable(feature = "rust1", since = "1.0.0")]
10501050
pub fn remove(&mut self, idx: usize) -> char {
10511051
let len = self.len();
1052-
assert!(idx <= len);
1052+
assert!(idx < len);
10531053

10541054
let ch = self.char_at(idx);
10551055
let next = idx + ch.len_utf8();

0 commit comments

Comments
 (0)