about summary refs log tree commit diff
path: root/library/std/src/io/error
diff options
context:
space:
mode:
authorJiahao XU <Jiahao_XU@outlook.com>2022-06-22 22:01:51 +1000
committerJiahao XU <Jiahao_XU@outlook.com>2022-06-22 22:01:51 +1000
commit1713e25a411c3854e85baa5fe076d5e3e8cffe35 (patch)
tree50a1752b0a74ec644e6acaed666c4df58b4ed2a4 /library/std/src/io/error
parentd11ff2a06e7977685c9f093ec667301d3e5f63c8 (diff)
downloadrust-1713e25a411c3854e85baa5fe076d5e3e8cffe35.tar.gz
rust-1713e25a411c3854e85baa5fe076d5e3e8cffe35.zip
Impl `io::error::repr_bitpacked::Repr::new`
that accepts `ErrorData<Box<Custom>>`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Diffstat (limited to 'library/std/src/io/error')
-rw-r--r--library/std/src/io/error/repr_bitpacked.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/library/std/src/io/error/repr_bitpacked.rs b/library/std/src/io/error/repr_bitpacked.rs
index e80068b46ab..292bf4826fd 100644
--- a/library/std/src/io/error/repr_bitpacked.rs
+++ b/library/std/src/io/error/repr_bitpacked.rs
@@ -132,6 +132,15 @@ unsafe impl Send for Repr {}
 unsafe impl Sync for Repr {}
 
 impl Repr {
+    pub(super) fn new(dat: ErrorData<Box<Custom>>) -> Self {
+        match dat {
+            ErrorData::Os(code) => Self::new_os(code),
+            ErrorData::Simple(kind) => Self::new_simple(kind),
+            ErrorData::SimpleMessage(simple_message) => Self::new_simple_message(simple_message),
+            ErrorData::Custom(b) => Self::new_custom(b),
+        }
+    }
+
     pub(super) fn new_custom(b: Box<Custom>) -> Self {
         let p = Box::into_raw(b).cast::<u8>();
         // Should only be possible if an allocator handed out a pointer with