Skip to content

Commit 1713e25

Browse files
committed
Impl io::error::repr_bitpacked::Repr::new
that accepts `ErrorData<Box<Custom>>` Signed-off-by: Jiahao XU <[email protected]>
1 parent d11ff2a commit 1713e25

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/std/src/io/error/repr_bitpacked.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ unsafe impl Send for Repr {}
132132
unsafe impl Sync for Repr {}
133133

134134
impl Repr {
135+
pub(super) fn new(dat: ErrorData<Box<Custom>>) -> Self {
136+
match dat {
137+
ErrorData::Os(code) => Self::new_os(code),
138+
ErrorData::Simple(kind) => Self::new_simple(kind),
139+
ErrorData::SimpleMessage(simple_message) => Self::new_simple_message(simple_message),
140+
ErrorData::Custom(b) => Self::new_custom(b),
141+
}
142+
}
143+
135144
pub(super) fn new_custom(b: Box<Custom>) -> Self {
136145
let p = Box::into_raw(b).cast::<u8>();
137146
// Should only be possible if an allocator handed out a pointer with

0 commit comments

Comments
 (0)