Rollup merge of #102470 - est31:stabilize_const_char_convert, r=joshtriplett
Stabilize const char convert Split out `const_char_from_u32_unchecked` from `const_char_convert` and stabilize the rest, i.e. stabilize the following functions: ```Rust impl char { pub const fn from_u32(self, i: u32) -> Option<char>; pub const fn from_digit(self, num: u32, radix: u32) -> Option<char>; pub const fn to_digit(self, radix: u32) -> Option<u32>; } // Available through core::char and std::char mod char { pub const fn from_u32(i: u32) -> Option<char>; pub const fn from_digit(num: u32, radix: u32) -> Option<char>; } ``` And put the following under the `from_u32_unchecked` const stability gate as it needs `Option::unwrap` which isn't const-stable (yet): ```Rust impl char { pub const unsafe fn from_u32_unchecked(i: u32) -> char; } // Available through core::char and std::char mod char { pub const unsafe fn from_u32_unchecked(i: u32) -> char; } ``` cc the tracking issue #89259 (which I'd like to keep open for `const_char_from_u32_unchecked`).
This commit is contained in:
commit
8c77da87d7
4 changed files with 8 additions and 9 deletions
|
@ -18,7 +18,6 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
|
|||
}
|
||||
|
||||
/// Converts a `u32` to a `char`, ignoring validity. See [`char::from_u32_unchecked`].
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
|
|
|
@ -140,7 +140,7 @@ impl char {
|
|||
/// assert_eq!(None, c);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_u32(i: u32) -> Option<char> {
|
||||
|
@ -183,7 +183,7 @@ impl char {
|
|||
/// assert_eq!('❤', c);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_unstable(feature = "const_char_from_u32_unchecked", issue = "89259")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
|
@ -241,7 +241,7 @@ impl char {
|
|||
/// let _c = char::from_digit(1, 37);
|
||||
/// ```
|
||||
#[stable(feature = "assoc_char_funcs", since = "1.52.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_digit(num: u32, radix: u32) -> Option<char> {
|
||||
|
@ -338,7 +338,7 @@ impl char {
|
|||
/// let _ = '1'.to_digit(37);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline]
|
||||
|
|
|
@ -110,7 +110,7 @@ pub fn decode_utf16<I: IntoIterator<Item = u16>>(iter: I) -> DecodeUtf16<I::Into
|
|||
|
||||
/// Converts a `u32` to a `char`. Use [`char::from_u32`] instead.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_u32(i: u32) -> Option<char> {
|
||||
|
@ -120,7 +120,7 @@ pub const fn from_u32(i: u32) -> Option<char> {
|
|||
/// Converts a `u32` to a `char`, ignoring validity. Use [`char::from_u32_unchecked`].
|
||||
/// instead.
|
||||
#[stable(feature = "char_from_unchecked", since = "1.5.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_unstable(feature = "const_char_from_u32_unchecked", issue = "89259")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
|
@ -130,7 +130,7 @@ pub const unsafe fn from_u32_unchecked(i: u32) -> char {
|
|||
|
||||
/// Converts a digit in the given radix to a `char`. Use [`char::from_digit`] instead.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_char_convert", issue = "89259")]
|
||||
#[rustc_const_stable(feature = "const_char_convert", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn from_digit(num: u32, radix: u32) -> Option<char> {
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
#![feature(const_black_box)]
|
||||
#![feature(const_caller_location)]
|
||||
#![feature(const_cell_into_inner)]
|
||||
#![feature(const_char_convert)]
|
||||
#![feature(const_char_from_u32_unchecked)]
|
||||
#![feature(const_clone)]
|
||||
#![feature(const_cmp)]
|
||||
#![feature(const_discriminant)]
|
||||
|
|
Loading…
Add table
Reference in a new issue