core: add From<core::ascii::char> implementations

Introduce `From<core::ascii::char>` implementations for all unsigned
numeric types and `char`.  This matches the API of `char` type.

Issue: https://github.com/rust-lang/rust/issues/110998
This commit is contained in:
Michal Nazarewicz 2024-01-24 16:03:44 +01:00
parent 5bd5d214ef
commit abf45ae0b2

View file

@ -537,6 +537,22 @@ impl AsciiChar {
}
}
macro_rules! into_int_impl {
($($ty:ty)*) => {
$(
#[unstable(feature = "ascii_char", issue = "110998")]
impl From<AsciiChar> for $ty {
#[inline]
fn from(chr: AsciiChar) -> $ty {
chr as u8 as $ty
}
}
)*
}
}
into_int_impl!(u8 u16 u32 u64 u128 char);
impl [AsciiChar] {
/// Views this slice of ASCII characters as a UTF-8 `str`.
#[unstable(feature = "ascii_char", issue = "110998")]