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.
This commit is contained in:
commit
02ea82ddb8
1 changed files with 0 additions and 4 deletions
|
@ -1129,8 +1129,6 @@ impl String {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn insert(&mut self, idx: usize, ch: char) {
|
pub fn insert(&mut self, idx: usize, ch: char) {
|
||||||
let len = self.len();
|
|
||||||
assert!(idx <= len);
|
|
||||||
assert!(self.is_char_boundary(idx));
|
assert!(self.is_char_boundary(idx));
|
||||||
let mut bits = [0; 4];
|
let mut bits = [0; 4];
|
||||||
let bits = ch.encode_utf8(&mut bits).as_bytes();
|
let bits = ch.encode_utf8(&mut bits).as_bytes();
|
||||||
|
@ -1184,7 +1182,6 @@ impl String {
|
||||||
reason = "recent addition",
|
reason = "recent addition",
|
||||||
issue = "35553")]
|
issue = "35553")]
|
||||||
pub fn insert_str(&mut self, idx: usize, string: &str) {
|
pub fn insert_str(&mut self, idx: usize, string: &str) {
|
||||||
assert!(idx <= self.len());
|
|
||||||
assert!(self.is_char_boundary(idx));
|
assert!(self.is_char_boundary(idx));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1288,7 +1285,6 @@ impl String {
|
||||||
#[unstable(feature = "string_split_off", issue = "38080")]
|
#[unstable(feature = "string_split_off", issue = "38080")]
|
||||||
pub fn split_off(&mut self, mid: usize) -> String {
|
pub fn split_off(&mut self, mid: usize) -> String {
|
||||||
assert!(self.is_char_boundary(mid));
|
assert!(self.is_char_boundary(mid));
|
||||||
assert!(mid <= self.len());
|
|
||||||
let other = self.vec.split_off(mid);
|
let other = self.vec.split_off(mid);
|
||||||
unsafe { String::from_utf8_unchecked(other) }
|
unsafe { String::from_utf8_unchecked(other) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue