From 1c8b7316503d3ab710d3d3ec241b85e76b9a42be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 1 Jan 2021 22:32:12 +0100 Subject: clippy pass --- mumctl/src/main.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'mumctl/src') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 27e27c4..d43ff4f 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -204,11 +204,8 @@ fn main() { ); let stdin = std::io::stdin(); let response = stdin.lock().lines().next(); - match response.map(|e| e.map(|e| &e == "Y")) { - Some(Ok(true)) => { - config.write_default_cfg(true).unwrap(); - } - _ => {} + if let Some(Ok(true)) = response.map(|e| e.map(|e| &e == "Y")) { + config.write_default_cfg(true).unwrap(); } } else { config.write_default_cfg(false).unwrap(); @@ -234,7 +231,7 @@ fn process_matches(matches: ArgMatches, config: &mut Config, app: &mut App) -> R } else if let Some(matches) = matches.subcommand_matches("add") { match_server_add(matches, config); } else if let Some(_) = matches.subcommand_matches("list") { - if config.servers.len() == 0 { + if config.servers.is_empty() { warn!("No servers in config"); } let query = config @@ -409,8 +406,7 @@ fn match_server_connect(matches: &clap::ArgMatches<'_>, config: &mumlib::config: let port = server_config.port.unwrap_or(port); let username = server_config .username - .as_ref() - .map(|e| e.as_str()) + .as_deref() .or(username); if username.is_none() { error!("no username specified"); @@ -525,17 +521,17 @@ fn match_server_config(matches: &clap::ArgMatches<'_>, config: &mut mumlib::conf server .port .map(|s| format!("port: {}\n", s)) - .unwrap_or("".to_string()), + .unwrap_or_else(|| "".to_string()), server .username .as_ref() .map(|s| format!("username: {}\n", s)) - .unwrap_or("".to_string()), + .unwrap_or_else(|| "".to_string()), server .password .as_ref() .map(|s| format!("password: {}\n", s)) - .unwrap_or("".to_string()), + .unwrap_or_else(|| "".to_string()), ) } } else { @@ -664,4 +660,4 @@ impl Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "Unable to connect to mumd. Is mumd running?") } -} \ No newline at end of file +} -- cgit v1.2.1