Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -1738,6 +1740,7 @@ impl EscapeDebugExtArgs {
}

#[inline]
#[must_use]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are private functions, so I don't think it matters much whether they are must_use, it seems very unlikely to cause problems if they aren't

const fn len_utf8(code: u32) -> usize {
match code {
..MAX_ONE_B => 1,
Expand All @@ -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 }
}
Expand Down
Loading