From b466fa6db8db80bad78c8e4b2f7516525c493a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Bj=C3=B8rnager=20Jensen?= Date: Wed, 25 Sep 2024 10:42:43 +0200 Subject: [PATCH] Add 'must_use' attribute to 'char::len_utf8' and 'char::len_utf16'; --- library/core/src/char/methods.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/char/methods.rs b/library/core/src/char/methods.rs index 3dcaab6a12beb..55e67e5c255e9 100644 --- a/library/core/src/char/methods.rs +++ b/library/core/src/char/methods.rs @@ -606,6 +606,7 @@ impl char { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_char_len_utf", since = "1.52.0")] #[inline] + #[must_use] pub const fn len_utf8(self) -> usize { len_utf8(self as u32) } @@ -637,6 +638,7 @@ impl char { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_char_len_utf", since = "1.52.0")] #[inline] + #[must_use] pub const fn len_utf16(self) -> usize { len_utf16(self as u32) } @@ -1738,6 +1740,7 @@ impl EscapeDebugExtArgs { } #[inline] +#[must_use] const fn len_utf8(code: u32) -> usize { match code { ..MAX_ONE_B => 1, @@ -1748,6 +1751,7 @@ const fn len_utf8(code: u32) -> usize { } #[inline] +#[must_use] const fn len_utf16(code: u32) -> usize { if (code & 0xFFFF) == code { 1 } else { 2 } }