From 40f4d51da8c799e3dfb525b99def8f2812689f6c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 19 Feb 2021 01:05:27 -0500 Subject: clippy --- src/bin/rbw/commands.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/bin/rbw/commands.rs') diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 3fa30f4..49c44a4 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -99,8 +99,8 @@ impl DecryptedCipher { for field in &self.fields { displayed |= self.display_field( - field.name.as_deref().unwrap_or_else(|| "(null)"), - Some(field.value.as_deref().unwrap_or_else(|| "")), + field.name.as_deref().unwrap_or("(null)"), + Some(field.value.as_deref().unwrap_or("")), ); } @@ -227,12 +227,11 @@ impl DecryptedCipher { if let Some(given_username) = username { match &self.data { - DecryptedData::Login { username, .. } => { - if let Some(found_username) = username { - if given_username != found_username { - return false; - } - } else { + DecryptedData::Login { + username: Some(found_username), + .. + } => { + if given_username != found_username { return false; } } @@ -273,12 +272,11 @@ impl DecryptedCipher { if let Some(given_username) = username { match &self.data { - DecryptedData::Login { username, .. } => { - if let Some(found_username) = username { - if !found_username.contains(given_username) { - return false; - } - } else { + DecryptedData::Login { + username: Some(found_username), + .. + } => { + if !found_username.contains(given_username) { return false; } } @@ -1391,14 +1389,14 @@ fn parse_editor(contents: &str) -> (Option, Option) { let password = lines.next().map(std::string::ToString::to_string); let mut notes: String = lines - .skip_while(|line| *line == "") + .skip_while(|line| line.is_empty()) .filter(|line| !line.starts_with('#')) .map(|line| format!("{}\n", line)) .collect(); while notes.ends_with('\n') { notes.pop(); } - let notes = if notes == "" { None } else { Some(notes) }; + let notes = if notes.is_empty() { None } else { Some(notes) }; (password, notes) } -- cgit v1.2.3-54-g00ecf