Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f51dde5

Browse files
committedMay 6, 2024
fix compiler errors
1 parent f4a78e0 commit f51dde5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎library/alloc/src/string.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
4343
#![stable(feature = "rust1", since = "1.0.0")]
4444

45-
use core::char::MAX_LEN_UTF8;
4645
use core::error::Error;
4746
use core::fmt;
4847
use core::hash;
@@ -1346,7 +1345,9 @@ impl String {
13461345
pub fn push(&mut self, ch: char) {
13471346
match ch.len_utf8() {
13481347
1 => self.vec.push(ch as u8),
1349-
_ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; MAX_LEN_UTF8]).as_bytes()),
1348+
_ => {
1349+
self.vec.extend_from_slice(ch.encode_utf8(&mut [0; char::MAX_LEN_UTF8]).as_bytes())
1350+
}
13501351
}
13511352
}
13521353

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

16511652
unsafe {
@@ -2634,7 +2635,7 @@ impl ToString for core::ascii::Char {
26342635
impl ToString for char {
26352636
#[inline]
26362637
fn to_string(&self) -> String {
2637-
String::from(self.encode_utf8(&mut [0; MAX_LEN_UTF8]))
2638+
String::from(self.encode_utf8(&mut [0; char::MAX_LEN_UTF8]))
26382639
}
26392640
}
26402641

0 commit comments

Comments
 (0)
Failed to load comments.