mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
chore: use map_or_else instead of if let Some() ... else
This commit is contained in:
parent
5d0834ac78
commit
f431508418
1 changed files with 4 additions and 5 deletions
|
|
@ -34,11 +34,10 @@ pub struct TcpSocket {
|
|||
|
||||
impl Socket for TcpSocket {
|
||||
fn new(address: &SocketAddr, timeout_settings: &Option<TimeoutSettings>) -> GDResult<Self> {
|
||||
let socket = if let Some(timeout) = TimeoutSettings::get_connect_or_default(timeout_settings) {
|
||||
net::TcpStream::connect_timeout(address, timeout)
|
||||
} else {
|
||||
net::TcpStream::connect(address)
|
||||
};
|
||||
let socket = TimeoutSettings::get_connect_or_default(timeout_settings).map_or_else(
|
||||
|| net::TcpStream::connect(address),
|
||||
|timeout| net::TcpStream::connect_timeout(address, timeout),
|
||||
);
|
||||
|
||||
let socket = Self {
|
||||
socket: socket.map_err(|e| SocketConnect.context(e))?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue