diff options
| author | Christopher Durham <cad97@cad97.com> | 2023-09-28 23:18:55 -0400 |
|---|---|---|
| committer | Christopher Durham <cad97@cad97.com> | 2023-09-28 23:56:10 -0400 |
| commit | 3d448bd067234283c32792bf2a96d63d65fb5e91 (patch) | |
| tree | de166af2877117b94bf52ea4bc0229660d343227 | |
| parent | 8047f8fb519bb5d9bb3c29652bb77b30369de7b5 (diff) | |
| download | rust-3d448bd067234283c32792bf2a96d63d65fb5e91.tar.gz rust-3d448bd067234283c32792bf2a96d63d65fb5e91.zip | |
style nits
Co-authored-by: David Tolnay <dtolnay@gmail.com>
| -rw-r--r-- | library/alloc/src/string.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index e29f5fb70ab..9a7d8213f42 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -741,7 +741,7 @@ impl String { return Err(FromUtf16Error(())); } match (cfg!(target_endian = "little"), unsafe { v.align_to::<u16>() }) { - (true, (&[], v, &[])) => Self::from_utf16(v), + (true, ([], v, [])) => Self::from_utf16(v), _ => decode_utf16(v.array_chunks::<2>().copied().map(u16::from_le_bytes)) .collect::<Result<_, _>>() .map_err(|_| FromUtf16Error(())), @@ -777,8 +777,8 @@ impl String { #[unstable(feature = "str_from_utf16_endian", issue = "none", reason = "recently added")] pub fn from_utf16le_lossy(v: &[u8]) -> String { match (cfg!(target_endian = "little"), unsafe { v.align_to::<u16>() }) { - (true, (&[], v, &[])) => Self::from_utf16_lossy(v), - (true, (&[], v, &[_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}", + (true, ([], v, [])) => Self::from_utf16_lossy(v), + (true, ([], v, [_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}", _ => { let mut iter = v.array_chunks::<2>(); let string = decode_utf16(iter.by_ref().copied().map(u16::from_le_bytes)) @@ -816,7 +816,7 @@ impl String { return Err(FromUtf16Error(())); } match (cfg!(target_endian = "big"), unsafe { v.align_to::<u16>() }) { - (true, (&[], v, &[])) => Self::from_utf16(v), + (true, ([], v, [])) => Self::from_utf16(v), _ => decode_utf16(v.array_chunks::<2>().copied().map(u16::from_be_bytes)) .collect::<Result<_, _>>() .map_err(|_| FromUtf16Error(())), @@ -852,8 +852,8 @@ impl String { #[unstable(feature = "str_from_utf16_endian", issue = "none", reason = "recently added")] pub fn from_utf16be_lossy(v: &[u8]) -> String { match (cfg!(target_endian = "big"), unsafe { v.align_to::<u16>() }) { - (true, (&[], v, &[])) => Self::from_utf16_lossy(v), - (true, (&[], v, &[_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}", + (true, ([], v, [])) => Self::from_utf16_lossy(v), + (true, ([], v, [_remainder])) => Self::from_utf16_lossy(v) + "\u{FFFD}", _ => { let mut iter = v.array_chunks::<2>(); let string = decode_utf16(iter.by_ref().copied().map(u16::from_be_bytes)) |
