about summary refs log tree commit diff
path: root/library/std/src/error.rs
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2022-01-07 20:20:55 -0800
committerGitHub <noreply@github.com>2022-01-07 20:20:55 -0800
commit83de77dd5e2b853b95a12ac8c6cc202eec81892b (patch)
tree57928649c0153e1430b43c8321f382440156a168 /library/std/src/error.rs
parente012a191d768adeda1ee36a99ef8b92d51920154 (diff)
parenta02639dc09fa0cde2cec73e6260d6702e165b8ce (diff)
Rollup merge of #84640 - ids1024:u8_from_char, r=m-ou-se
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/src/error.rs')
-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>