From 3d448bd067234283c32792bf2a96d63d65fb5e91 Mon Sep 17 00:00:00 2001 From: Christopher Durham Date: Thu, 28 Sep 2023 23:18:55 -0400 Subject: [PATCH] style nits Co-authored-by: David Tolnay --- library/alloc/src/string.rs | 12 ++++++------ 1 file 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 @@ pub fn from_utf16le(v: &[u8]) -> Result { return Err(FromUtf16Error(())); } match (cfg!(target_endian = "little"), unsafe { v.align_to::() }) { - (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::>() .map_err(|_| FromUtf16Error(())), @@ -777,8 +777,8 @@ pub fn from_utf16le(v: &[u8]) -> Result { #[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::() }) { - (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 @@ pub fn from_utf16be(v: &[u8]) -> Result { return Err(FromUtf16Error(())); } match (cfg!(target_endian = "big"), unsafe { v.align_to::() }) { - (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::>() .map_err(|_| FromUtf16Error(())), @@ -852,8 +852,8 @@ pub fn from_utf16be(v: &[u8]) -> Result { #[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::() }) { - (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))