diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-01-01 22:32:12 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-01-01 22:40:08 +0100 |
| commit | 1c8b7316503d3ab710d3d3ec241b85e76b9a42be (patch) | |
| tree | 95e85a9f7bd26b6901e6cbe5e9ca29f8d60053e5 /mumctl/src/main.rs | |
| parent | 67364577263943e815be9ba700c10845698e116d (diff) | |
| download | mum-1c8b7316503d3ab710d3d3ec241b85e76b9a42be.tar.gz | |
clippy pass
Diffstat (limited to 'mumctl/src/main.rs')
| -rw-r--r-- | mumctl/src/main.rs | 20 |
1 files changed, 8 insertions, 12 deletions
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 +} |
