Skip to content

Commit abf45ae

Browse files
committed
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: #110998
1 parent 5bd5d21 commit abf45ae

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

library/core/src/ascii/ascii_char.rs

+16
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,22 @@ impl AsciiChar {
537537
}
538538
}
539539

540+
macro_rules! into_int_impl {
541+
($($ty:ty)*) => {
542+
$(
543+
#[unstable(feature = "ascii_char", issue = "110998")]
544+
impl From<AsciiChar> for $ty {
545+
#[inline]
546+
fn from(chr: AsciiChar) -> $ty {
547+
chr as u8 as $ty
548+
}
549+
}
550+
)*
551+
}
552+
}
553+
554+
into_int_impl!(u8 u16 u32 u64 u128 char);
555+
540556
impl [AsciiChar] {
541557
/// Views this slice of ASCII characters as a UTF-8 `str`.
542558
#[unstable(feature = "ascii_char", issue = "110998")]

0 commit comments

Comments
 (0)