Skip to content

Commit 9fd203a

Browse files
committed
simplify code
1 parent 127311b commit 9fd203a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/libstd/sys/wasi/thread.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ impl Thread {
4646
type_: wasi::EVENTTYPE_CLOCK,
4747
u: wasi::raw::__wasi_subscription_u { clock: clock },
4848
}];
49-
let mut out: [wasi::Event; 1] = [unsafe { mem::zeroed() }];
50-
let n = unsafe { wasi::poll_oneoff(&in_, &mut out).unwrap() };
51-
let wasi::Event { userdata, error, type_, .. } = out[0];
52-
match (n, userdata, error) {
53-
(1, CLOCK_ID, 0) if type_ == wasi::EVENTTYPE_CLOCK => {}
49+
let (res, event) = unsafe {
50+
let mut out: [wasi::Event; 1] = mem::zeroed();
51+
let res = wasi::poll_oneoff(&in_, &mut out);
52+
(res, out[0])
53+
};
54+
match (res, event) {
55+
(Ok(1), wasi::Event {
56+
userdata: CLOCK_ID,
57+
error: 0,
58+
type_: wasi::EVENTTYPE_CLOCK,
59+
..
60+
}) => {}
5461
_ => panic!("thread::sleep(): unexpected result of poll_oneoff"),
5562
}
5663
}

0 commit comments

Comments
 (0)