-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MAX_UTF{8, 16}_LEN
constants
#98198
Changes from all commits
a9297b4
05b19e4
ccb013c
31c555d
5b417e2
c3c6d9e
5155ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,17 @@ pub const REPLACEMENT_CHARACTER: char = char::REPLACEMENT_CHARACTER; | |
#[stable(feature = "unicode_version", since = "1.45.0")] | ||
pub const UNICODE_VERSION: (u8, u8, u8) = char::UNICODE_VERSION; | ||
|
||
/// The maximum number of bytes required to [encode](char::encode_utf8) a | ||
/// `char` in UTF-8. Use [`char::MAX_UTF8_LEN`] instead. | ||
#[stable(feature = "max_len", since = "1.63.0")] | ||
pub const MAX_UTF8_LEN: usize = char::MAX_UTF8_LEN; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pondering: are the module-level constants still desirable, now that we can have type-associated ones? It's unclear to me how to apply precedent from #68490 here -- the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeh i didn't think of type-associated ones, will change it to that |
||
|
||
/// The maximum number of 16-bit code units required to | ||
/// [encode](char::encode_utf16) a `char` in UTF-16. Use [`char::MAX_UTF16_LEN`] | ||
/// instead. | ||
#[stable(feature = "max_len", since = "1.63.0")] | ||
pub const MAX_UTF16_LEN: usize = char::MAX_UTF16_LEN; | ||
|
||
/// Creates an iterator over the UTF-16 encoded code points in `iter`, returning | ||
/// unpaired surrogates as `Err`s. Use [`char::decode_utf16`] instead. | ||
#[stable(feature = "decode_utf16", since = "1.9.0")] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should go in
unstable
with a tracking issue, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could but i thought since these were constants that replaced literal values we could directly stabilise them. I'm fine with adding unstable feature if that's the way to go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's basically three possible ways forward:
pub(crate)
and it goes in with aT-libs
review.T-libs-api
FCP.Basically we only do 3 if forced (because some things can't go in unstable). So please make it unstable with a tracking issue, and then it can just be approved. (Consider also doing some commit squashing.)