]> git.lizzy.rs Git - rust.git/commitdiff
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)
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`).

1  2 
library/core/src/char/methods.rs
library/core/src/lib.rs

Simple merge
Simple merge