Skip to content

Commit 5facc32

Browse files
committed
fix char imports
1 parent 1efea31 commit 5facc32

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

library/alloc/src/string.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ impl String {
742742
}
743743
match (cfg!(target_endian = "little"), unsafe { v.align_to::<u16>() }) {
744744
(true, ([], v, [])) => Self::from_utf16(v),
745-
_ => decode_utf16(v.array_chunks::<2>().copied().map(u16::from_le_bytes))
745+
_ => char::decode_utf16(v.array_chunks::<2>().copied().map(u16::from_le_bytes))
746746
.collect::<Result<_, _>>()
747747
.map_err(|_| FromUtf16Error(())),
748748
}
@@ -781,8 +781,8 @@ impl String {
781781
(true, ([], v, [_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}",
782782
_ => {
783783
let mut iter = v.array_chunks::<2>();
784-
let string = decode_utf16(iter.by_ref().copied().map(u16::from_le_bytes))
785-
.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
784+
let string = char::decode_utf16(iter.by_ref().copied().map(u16::from_le_bytes))
785+
.map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
786786
.collect();
787787
if iter.remainder().is_empty() { string } else { string + "\u{FFFD}" }
788788
}
@@ -817,7 +817,7 @@ impl String {
817817
}
818818
match (cfg!(target_endian = "big"), unsafe { v.align_to::<u16>() }) {
819819
(true, ([], v, [])) => Self::from_utf16(v),
820-
_ => decode_utf16(v.array_chunks::<2>().copied().map(u16::from_be_bytes))
820+
_ => char::decode_utf16(v.array_chunks::<2>().copied().map(u16::from_be_bytes))
821821
.collect::<Result<_, _>>()
822822
.map_err(|_| FromUtf16Error(())),
823823
}
@@ -856,8 +856,8 @@ impl String {
856856
(true, ([], v, [_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}",
857857
_ => {
858858
let mut iter = v.array_chunks::<2>();
859-
let string = decode_utf16(iter.by_ref().copied().map(u16::from_be_bytes))
860-
.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
859+
let string = char::decode_utf16(iter.by_ref().copied().map(u16::from_be_bytes))
860+
.map(|r| r.unwrap_or(char::REPLACEMENT_CHARACTER))
861861
.collect();
862862
if iter.remainder().is_empty() { string } else { string + "\u{FFFD}" }
863863
}

0 commit comments

Comments
 (0)