Appease clippy.

This commit is contained in:
Todd Mortimer 2021-03-20 14:26:52 -04:00
parent ec835d67e4
commit d0e61c73e9
2 changed files with 9 additions and 12 deletions

View file

@ -1459,7 +1459,7 @@ impl<T: Read + Write> Connection<T> {
// Remove CRLF // Remove CRLF
let len = into.len(); let len = into.len();
let line = &into[(len - read)..(len - 2)]; let line = &into[(len - read)..(len - 2)];
eprint!("S: {}\n", String::from_utf8_lossy(line)); eprintln!("S: {}", String::from_utf8_lossy(line));
} }
Ok(read) Ok(read)
@ -1475,7 +1475,7 @@ impl<T: Read + Write> Connection<T> {
self.stream.write_all(&[CR, LF])?; self.stream.write_all(&[CR, LF])?;
self.stream.flush()?; self.stream.flush()?;
if self.debug { if self.debug {
eprint!("C: {}\n", String::from_utf8(buf.to_vec()).unwrap()); eprintln!("C: {}", String::from_utf8(buf.to_vec()).unwrap());
} }
Ok(()) Ok(())
} }

View file

@ -34,7 +34,7 @@ impl CmdListItemFormat for Metadata {
self.value self.value
.as_ref() .as_ref()
.map(|v| validate_str(v.as_str()).unwrap()) .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 { impl MetadataDepth {
fn depth_str<'a>(self) -> &'a str { fn depth_str<'a>(self) -> &'a str {
match self { match self {
MetadataDepth::Zero => return "0", MetadataDepth::Zero => "0",
MetadataDepth::One => return "1", MetadataDepth::One => "1",
MetadataDepth::Infinity => return "infinity", MetadataDepth::Infinity => "infinity",
} }
} }
} }
@ -175,18 +175,15 @@ impl<T: Read + Write> Session<T> {
let s = v.as_slice().join(" "); let s = v.as_slice().join(" ");
let mut command = format!("GETMETADATA (DEPTH {}", depth.depth_str()); let mut command = format!("GETMETADATA (DEPTH {}", depth.depth_str());
match maxsize { if let Some(size) = maxsize {
Some(size) => { command.push_str(format!(" MAXSIZE {}", size).as_str());
command.push_str(format!(" MAXSIZE {}", size).as_str());
}
_ => {}
} }
command.push_str( command.push_str(
format!( format!(
") {} ({})", ") {} ({})",
mailbox mailbox
.map(|mbox| validate_str(mbox.as_ref()).unwrap()) .map(|mbox| validate_str(mbox).unwrap())
.unwrap_or_else(|| "\"\"".to_string()), .unwrap_or_else(|| "\"\"".to_string()),
s s
) )