Fix a few clippy issues

This commit is contained in:
Nick Mathewson 2020-09-27 03:30:09 -04:00
parent 2feb750ba1
commit 397d753e4e
4 changed files with 8 additions and 9 deletions

View File

@ -247,10 +247,7 @@ impl RelayMsg {
pub fn counts_towards_windows(&self) -> bool {
// TODO Instead of looking at !sendme, tor looks at data. We
// should document and make the spec conform.
match self {
RelayMsg::Sendme(_) => false,
_ => true,
}
matches!(self, RelayMsg::Sendme(_))
}
}

View File

@ -136,8 +136,8 @@ impl NetDirConfig {
pub fn add_authority(&mut self, name: &str, ident: &str) -> Result<()> {
let ident: Vec<u8> =
hex::decode(ident).map_err(|_| Error::BadArgument("bad hex identity"))?;
let v3ident = RSAIdentity::from_bytes(&ident)
.ok_or_else(|| Error::BadArgument("wrong identity length"))?;
let v3ident =
RSAIdentity::from_bytes(&ident).ok_or(Error::BadArgument("wrong identity length"))?;
self.authorities.push(Authority {
name: name.to_string(),
v3ident,

View File

@ -139,8 +139,8 @@ impl<'a, K: Keyword> NetDocReaderBase<'a, K> {
fn get_kwdline(&mut self) -> Result<(&'a str, &'a str)> {
let pos = self.off;
let line = self.get_line()?;
let (line, anno_ok) = if line.starts_with("opt ") {
(&line[4..], false)
let (line, anno_ok) = if let Some(rem) = line.strip_prefix("opt ") {
(rem, false)
} else {
(line, true)
};

View File

@ -57,7 +57,9 @@ impl TorStream {
.await
// This probably means that the other side closed the
// mpsc channel.
.ok_or_else(|| Error::StreamClosed("stream channel disappeared without END cell?"))?;
.ok_or(Error::StreamClosed(
"stream channel disappeared without END cell?",
))?;
// Possibly decrement the window for the cell we just received, and
// send a SENDME if doing so took us under the threshold.