Skip to content

Commit

Permalink
core: add From<core::ascii::char> implementations
Browse files Browse the repository at this point in the history
Introduce `From<core::ascii::char>` implementations for all unsigned
numeric types and `char`.  This matches the API of `char` type.

Issue: #110998
  • Loading branch information
mina86 committed Jan 25, 2024
1 parent 5bd5d21 commit abf45ae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/core/src/ascii/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit abf45ae

Please sign in to comment.