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:
parent
5bd5d214ef
commit
abf45ae0b2
1 changed files with 16 additions and 0 deletions
|
@ -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] {
|
impl [AsciiChar] {
|
||||||
/// Views this slice of ASCII characters as a UTF-8 `str`.
|
/// Views this slice of ASCII characters as a UTF-8 `str`.
|
||||||
#[unstable(feature = "ascii_char", issue = "110998")]
|
#[unstable(feature = "ascii_char", issue = "110998")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue