Cargo clippy: fix the majority of errors
This commit is contained in:
parent
871d927596
commit
6968a4e449
19 changed files with 69 additions and 91 deletions
|
|
@ -113,12 +113,12 @@ impl std::fmt::Display for ErrorContext {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let mut it = self.field_stack.iter();
|
||||
if let Some(field) = it.next() {
|
||||
write!(f, "\"{}\"", field)?;
|
||||
write!(f, "\"{field}\"")?;
|
||||
} else {
|
||||
return Ok(());
|
||||
}
|
||||
for field in self.field_stack.iter().skip(1) {
|
||||
write!(f, " -> \"{}\"", field)?;
|
||||
write!(f, " -> \"{field}\"")?;
|
||||
}
|
||||
f.write_str(": ")
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ impl std::fmt::Display for ErrorKind {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
ErrorKind::Other(err) => err.fmt(f),
|
||||
ErrorKind::NotSupported(s) => write!(f, "{} is not supported by bencode", s),
|
||||
ErrorKind::NotSupported(s) => write!(f, "{s} is not supported by bencode"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ impl Error {
|
|||
}
|
||||
fn set_context(mut self, de: &BencodeDeserializer<'_>) -> Self {
|
||||
self.context = ErrorContext {
|
||||
field_stack: de.field_context.iter().map(|s| format!("{}", s)).collect(),
|
||||
field_stack: de.field_context.iter().map(|s| format!("{s}")).collect(),
|
||||
};
|
||||
self
|
||||
}
|
||||
|
|
@ -427,7 +427,7 @@ impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut BencodeDeserializer<'de>
|
|||
}
|
||||
self.buf = self.buf.get(1..).unwrap_or_default();
|
||||
visitor
|
||||
.visit_seq(SeqAccess { de: &mut self })
|
||||
.visit_seq(SeqAccess { de: self })
|
||||
.map_err(|e: Self::Error| e.set_context(self))
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut BencodeDeserializer<'de>
|
|||
}
|
||||
self.buf = self.buf.get(1..).unwrap_or_default();
|
||||
visitor
|
||||
.visit_map(MapAccess { de: &mut self })
|
||||
.visit_map(MapAccess { de: self })
|
||||
.map_err(|e: Self::Error| e.set_context(self))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub enum SerErrorKind {
|
|||
impl std::fmt::Display for SerErrorKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
SerErrorKind::Other(e) => write!(f, "{}", e),
|
||||
SerErrorKind::Other(e) => write!(f, "{e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ impl<W: std::io::Write> BencodeSerializer<W> {
|
|||
self.write_raw(&[byte])
|
||||
}
|
||||
fn write_number<N: std::fmt::Display>(&mut self, number: N) -> Result<(), SerError> {
|
||||
self.write_fmt(format_args!("i{}e", number))
|
||||
self.write_fmt(format_args!("i{number}e"))
|
||||
}
|
||||
fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), SerError> {
|
||||
if !self.hack_no_bytestring_prefix {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue