From 1713e25a411c3854e85baa5fe076d5e3e8cffe35 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 22 Jun 2022 22:01:51 +1000 Subject: [PATCH] Impl `io::error::repr_bitpacked::Repr::new` that accepts `ErrorData>` Signed-off-by: Jiahao XU --- library/std/src/io/error/repr_bitpacked.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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>) -> 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) -> Self { let p = Box::into_raw(b).cast::(); // Should only be possible if an allocator handed out a pointer with