From dafc14794f9d71b3ccc5fde0aeb47cd6bb25e83e Mon Sep 17 00:00:00 2001 From: ibraheemdev Date: Mon, 30 Aug 2021 14:00:21 -0400 Subject: [PATCH] clean up `c::linger` conversion --- library/std/src/sys/unix/net.rs | 2 +- library/std/src/sys/windows/net.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index d2e8c43a665..9ae6d12dcb9 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -387,7 +387,7 @@ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { pub fn set_linger(&self, linger: Option) -> io::Result<()> { let linger = libc::linger { l_onoff: linger.is_some() as libc::c_int, - l_linger: linger.map(|dur| dur.as_secs() as libc::c_int).unwrap_or_default(), + l_linger: linger.unwrap_or_default().as_secs() as libc::c_int, }; setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger) diff --git a/library/std/src/sys/windows/net.rs b/library/std/src/sys/windows/net.rs index 1ad4f0c70a3..33152cc97ab 100644 --- a/library/std/src/sys/windows/net.rs +++ b/library/std/src/sys/windows/net.rs @@ -449,7 +449,7 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { pub fn set_linger(&self, linger: Option) -> io::Result<()> { let linger = c::linger { l_onoff: linger.is_some() as c_ushort, - l_linger: linger.map(|dur| dur.as_secs() as c_ushort).unwrap_or_default(), + l_linger: linger.unwrap_or_default().as_secs() as c_ushort, }; net::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) -- GitLab