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
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<T: Read + Write> Connection<T> {
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(())
}

View file

@ -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<T: Read + Write> Session<T> {
let s = v.as_slice().join(" ");
let mut command = format!("GETMETADATA (DEPTH {}", depth.depth_str());
match maxsize {
Some(size) => {
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
)