diff options
| author | bors <bors@rust-lang.org> | 2016-01-03 21:00:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-01-03 21:00:46 +0000 |
| commit | 8f11a9ef4e23db189676c57c91c2675e97a74fea (patch) | |
| tree | abe17def78f47e79ad89c67b4a5ffeb5feef7d3f | |
| parent | cae9267d4735fa84cf7758b000ae1d64bdbac55c (diff) | |
| parent | 8b398ed8235c518dea5f29d80f8a337b7c6744cf (diff) | |
| download | rust-8f11a9ef4e23db189676c57c91c2675e97a74fea.tar.gz rust-8f11a9ef4e23db189676c57c91c2675e97a74fea.zip | |
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.
| -rw-r--r-- | src/libcollections/string.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 931092f6924..d2cbcad875f 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1029,8 +1029,8 @@ impl String { /// /// # Panics /// - /// Panics if `idx` is larger than the `String`'s length, or if it does not - /// lie on a [`char`] boundary. + /// Panics if `idx` is larger than or equal to the `String`'s length, + /// or if it does not lie on a [`char`] boundary. /// /// [`char`]: ../primitive.char.html /// @@ -1049,7 +1049,7 @@ impl String { #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, idx: usize) -> char { let len = self.len(); - assert!(idx <= len); + assert!(idx < len); let ch = self.char_at(idx); let next = idx + ch.len_utf8(); |
