From 0fc1a7da93e5d431f5cd54a3f1263e2a5f9e5748 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Tue, 24 Feb 2015 17:07:13 +0100 Subject: Improve readability of an error check in `set_non_blocking` --- src/libstd/sys/windows/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libstd/sys/windows') diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index a13c03c7448..3acb372f658 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -194,11 +194,11 @@ pub fn wouldblock() -> bool { pub fn set_nonblocking(fd: sock_t, nb: bool) { let mut set = nb as libc::c_ulong; - (if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 { - Err(last_error()) - } else { - Ok(()) - }).unwrap(); + if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 { + // The above function should not return an error unless we passed it + // invalid parameters. Panic on errors. + Err(last_error()).unwrap(); + } } pub fn init_net() { -- cgit 1.4.1-3-g733a5