Skip to content

Commit

Permalink
fix compiler errors
Browse files Browse the repository at this point in the history
  • Loading branch information
HTGAzureX1212 committed May 6, 2024
1 parent f4a78e0 commit f51dde5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#![stable(feature = "rust1", since = "1.0.0")]

use core::char::MAX_LEN_UTF8;
use core::error::Error;
use core::fmt;
use core::hash;
Expand Down Expand Up @@ -1346,7 +1345,9 @@ impl String {
pub fn push(&mut self, ch: char) {
match ch.len_utf8() {
1 => self.vec.push(ch as u8),
_ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; MAX_LEN_UTF8]).as_bytes()),
_ => {
self.vec.extend_from_slice(ch.encode_utf8(&mut [0; char::MAX_LEN_UTF8]).as_bytes())
}
}
}

Expand Down Expand Up @@ -1645,7 +1646,7 @@ impl String {
#[rustc_confusables("set")]
pub fn insert(&mut self, idx: usize, ch: char) {
assert!(self.is_char_boundary(idx));
let mut bits = [0; MAX_LEN_UTF8];
let mut bits = [0; char::MAX_LEN_UTF8];
let bits = ch.encode_utf8(&mut bits).as_bytes();

unsafe {
Expand Down Expand Up @@ -2634,7 +2635,7 @@ impl ToString for core::ascii::Char {
impl ToString for char {
#[inline]
fn to_string(&self) -> String {
String::from(self.encode_utf8(&mut [0; MAX_LEN_UTF8]))
String::from(self.encode_utf8(&mut [0; char::MAX_LEN_UTF8]))
}
}

Expand Down

0 comments on commit f51dde5

Please sign in to comment.