From d0e61c73e9f8e8c38a9f7683d63ce75db78fc55c Mon Sep 17 00:00:00 2001 From: Todd Mortimer Date: Sat, 20 Mar 2021 14:26:52 -0400 Subject: [PATCH] Appease clippy. --- src/client.rs | 4 ++-- src/extensions/metadata.rs | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/client.rs b/src/client.rs index e13dfd6..a5ddc5c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1459,7 +1459,7 @@ impl Connection { // Remove CRLF let len = into.len(); let line = &into[(len - read)..(len - 2)]; - eprint!("S: {}\n", String::from_utf8_lossy(line)); + eprintln!("S: {}", String::from_utf8_lossy(line)); } Ok(read) @@ -1475,7 +1475,7 @@ impl Connection { self.stream.write_all(&[CR, LF])?; self.stream.flush()?; if self.debug { - eprint!("C: {}\n", String::from_utf8(buf.to_vec()).unwrap()); + eprintln!("C: {}", String::from_utf8(buf.to_vec()).unwrap()); } Ok(()) } diff --git a/src/extensions/metadata.rs b/src/extensions/metadata.rs index 726c275..619a214 100644 --- a/src/extensions/metadata.rs +++ b/src/extensions/metadata.rs @@ -34,7 +34,7 @@ impl CmdListItemFormat for Metadata { self.value .as_ref() .map(|v| validate_str(v.as_str()).unwrap()) - .unwrap_or("NIL".to_string()) + .unwrap_or_else(|| "NIL".to_string()) ) } } @@ -69,9 +69,9 @@ impl Default for MetadataDepth { impl MetadataDepth { fn depth_str<'a>(self) -> &'a str { match self { - MetadataDepth::Zero => return "0", - MetadataDepth::One => return "1", - MetadataDepth::Infinity => return "infinity", + MetadataDepth::Zero => "0", + MetadataDepth::One => "1", + MetadataDepth::Infinity => "infinity", } } } @@ -175,18 +175,15 @@ impl Session { let s = v.as_slice().join(" "); let mut command = format!("GETMETADATA (DEPTH {}", depth.depth_str()); - match maxsize { - Some(size) => { - command.push_str(format!(" MAXSIZE {}", size).as_str()); - } - _ => {} + if let Some(size) = maxsize { + command.push_str(format!(" MAXSIZE {}", size).as_str()); } command.push_str( format!( ") {} ({})", mailbox - .map(|mbox| validate_str(mbox.as_ref()).unwrap()) + .map(|mbox| validate_str(mbox).unwrap()) .unwrap_or_else(|| "\"\"".to_string()), s )