about summary refs log tree commit diff
path: root/library/std
diff options
context:
space:
mode:
authorIan Douglas Scott <ian@iandouglasscott.com>2021-04-27 21:05:26 -0700
committerIan Douglas Scott <idscott@system76.com>2022-01-07 12:28:47 -0800
commita02639dc09fa0cde2cec73e6260d6702e165b8ce (patch)
tree57928649c0153e1430b43c8321f382440156a168 /library/std
parente012a191d768adeda1ee36a99ef8b92d51920154 (diff)
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>`.
Diffstat (limited to 'library/std')
-rw-r--r--library/std/src/error.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/std/src/error.rs b/library/std/src/error.rs
index 6ae0bc47a94..ea0c230fa42 100644
--- a/library/std/src/error.rs
+++ b/library/std/src/error.rs
@@ -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>