From 6e77d001bd7e32120bf6ad426da9c8f10dffc716 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Mon, 17 Dec 2018 05:58:22 -0800 Subject: Fix two clippy warnings After the switch to using the nitrokey crate for communication with the device, we have to warnings standing in the way of enabling clippy unconditionally for the nitrocli crate. This change fixes those two warnings. --- nitrocli/src/pinentry.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nitrocli/src/pinentry.rs') diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs index 1f1b02a..66ca6be 100644 --- a/nitrocli/src/pinentry.rs +++ b/nitrocli/src/pinentry.rs @@ -77,7 +77,7 @@ fn parse_pinentry_passphrase(response: Vec) -> Result, Error> { // Check if we are dealing with a special "ERR " line and report that // specially. - if lines.len() >= 1 && lines[0].starts_with("ERR ") { + if !lines.is_empty() && lines[0].starts_with("ERR ") { let (_, error) = lines[0].split_at(4); return Err(Error::Error(error.to_string())); } @@ -91,7 +91,7 @@ fn parse_pinentry_passphrase(response: Vec) -> Result, Error> { /// if available. If an error message is set, it is displayed in the passphrase dialog. pub fn inquire_passphrase(pin_type: PinType, error_msg: Option<&str>) -> Result, Error> { let cache_id = pin_type.cache_id(); - let error_msg = error_msg.map(|msg| msg.replace(" ", "+")).unwrap_or(String::from("+")); + let error_msg = error_msg.map(|msg| msg.replace(" ", "+")).unwrap_or_else(|| String::from("+")); let prompt = pin_type.prompt(); let description = pin_type.description().replace(" ", "+"); -- cgit v1.2.1