]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #102470 - est31:stabilize_const_char_convert, r=joshtriplett
authorMatthias Krüger <matthias.krueger@famsik.de>
Mon, 14 Nov 2022 18:26:15 +0000 (19:26 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Nov 2022 18:26:15 +0000 (19:26 +0100)
commit8c77da87d7451f275259c43c89ac3c9c24c1c8c8
tree89fc15caaf1dd49a2053042c56308385a897e41b
parent9f3786b2b1f3450c796041175f08a7cae7da42f3
parent176c44c08ed797b5ddea893a0a292a7bee0d8f8c
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`).
library/core/src/char/methods.rs
library/core/src/lib.rs