Rollup merge of #130819 - bjoernager:char-must-use-len-utf, r=Noratrieb · qinheping/verify-rust-std@d50c54a (original) (raw)

Original file line number Diff line number Diff line change
@@ -606,6 +606,7 @@ impl char {
606 606 #[stable(feature = "rust1", since = "1.0.0")]
607 607 #[rustc_const_stable(feature = "const_char_len_utf", since = "1.52.0")]
608 608 #[inline]
609 +#[must_use]
609 610 pub const fn len_utf8(self) -> usize {
610 611 len_utf8(self as u32)
611 612 }
@@ -637,6 +638,7 @@ impl char {
637 638 #[stable(feature = "rust1", since = "1.0.0")]
638 639 #[rustc_const_stable(feature = "const_char_len_utf", since = "1.52.0")]
639 640 #[inline]
641 +#[must_use]
640 642 pub const fn len_utf16(self) -> usize {
641 643 len_utf16(self as u32)
642 644 }
@@ -1738,6 +1740,7 @@ impl EscapeDebugExtArgs {
1738 1740 }
1739 1741
1740 1742 #[inline]
1743 +#[must_use]
1741 1744 const fn len_utf8(code: u32) -> usize {
1742 1745 match code {
1743 1746 ..MAX_ONE_B => 1,
@@ -1748,6 +1751,7 @@ const fn len_utf8(code: u32) -> usize {
1748 1751 }
1749 1752
1750 1753 #[inline]
1754 +#[must_use]
1751 1755 const fn len_utf16(code: u32) -> usize {
1752 1756 if (code & 0xFFFF) == code { 1 } else { 2 }
1753 1757 }