From 44abf6ec71706375d534255c457418bdf3f830b6 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Mon, 11 Dec 2023 04:00:31 +0200 Subject: [PATCH] chore: use Option::map_or_else instead of an if let/else --- crates/cli/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 526f227..e908ec2 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -85,13 +85,14 @@ fn find_game(game_id: &str) -> Result<&'static Game> { /// * `Result` - On sucess returns a resolved IP address; on failure /// returns an [Error::InvalidHostname] error. fn resolve_ip_or_domain(host: &str, extra_options: &mut Option) -> Result { - if let Ok(parsed_ip) = host.parse() { - Ok(parsed_ip) - } else { - set_hostname_if_missing(host, extra_options); + host.parse().map_or_else( + |_| { + set_hostname_if_missing(host, extra_options); - resolve_domain(host) - } + resolve_domain(host) + }, + |parsed_ip| Ok(parsed_ip), + ) } /// Resolve a domain name to one of its IP addresses (the first one returned).