Implement TryFrom<char> for u8

Previously suggested in https://github.com/rust-lang/rfcs/issues/2854.

It makes sense to have this since `char` implements `From<u8>`. Likewise
`u32`, `u64`, and `u128` (since #79502) implement `From<char>`.
This commit is contained in:
Ian Douglas Scott
2021-04-27 21:05:26 -07:00
committed by Ian Douglas Scott
parent e012a191d7
commit a02639dc09
3 changed files with 30 additions and 0 deletions

View File

@@ -478,6 +478,9 @@ impl Error for char::DecodeUtf16Error {
}
}
#[stable(feature = "u8_from_char", since = "1.59.0")]
impl Error for char::TryFromCharError {}
#[unstable(feature = "map_try_insert", issue = "82766")]
impl<'a, K: Debug + Ord, V: Debug> Error
for crate::collections::btree_map::OccupiedError<'a, K, V>