Skip to content

Commit 0fc1a7d

Browse files
committed
Improve readability of an error check in set_non_blocking
1 parent d0c589d commit 0fc1a7d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libstd/sys/windows/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ pub fn wouldblock() -> bool {
194194

195195
pub fn set_nonblocking(fd: sock_t, nb: bool) {
196196
let mut set = nb as libc::c_ulong;
197-
(if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 {
198-
Err(last_error())
199-
} else {
200-
Ok(())
201-
}).unwrap();
197+
if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 {
198+
// The above function should not return an error unless we passed it
199+
// invalid parameters. Panic on errors.
200+
Err(last_error()).unwrap();
201+
}
202202
}
203203

204204
pub fn init_net() {

0 commit comments

Comments
 (0)