clippy fixes

This commit is contained in:
Robin Appelman 2021-07-29 16:48:33 +02:00
commit b3b38b335b

View file

@ -41,7 +41,7 @@ pub fn real_ip(
} }
// all hops were trusted, return the last one // all hops were trusted, return the last one
forwarded_for.first().copied().unwrap_or(addr.ip()) forwarded_for.first().copied().unwrap_or_else(|| addr.ip())
}) })
}, },
) )
@ -72,7 +72,7 @@ pub fn get_forwarded_for() -> impl Filter<Extract = (Vec<IpAddr>,), Error = Infa
.collect::<Vec<_>>() .collect::<Vec<_>>()
})) }))
.unify() .unify()
.or(warp::any().map(|| vec![])) .or(warp::any().map(Vec::new))
.unify() .unify()
} }
@ -110,9 +110,8 @@ impl<'a> Iterator for CommaSeparatedIterator<'a> {
type Item = &'a str; type Item = &'a str;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
loop { while let Some((i, c)) = self.char_indices.next() {
match self.char_indices.next() { match match self.state {
Some((i, c)) => match match self.state {
CommaSeparatedIteratorState::Default => match c { CommaSeparatedIteratorState::Default => match c {
'"' => { '"' => {
self.s = i; self.s = i;
@ -158,11 +157,9 @@ impl<'a> Iterator for CommaSeparatedIterator<'a> {
(None, next_state) => { (None, next_state) => {
self.state = next_state; self.state = next_state;
} }
},
None => break,
} }
} }
return match self.state { match self.state {
CommaSeparatedIteratorState::Default CommaSeparatedIteratorState::Default
| CommaSeparatedIteratorState::PostAmbleForQuoted => None, | CommaSeparatedIteratorState::PostAmbleForQuoted => None,
CommaSeparatedIteratorState::Quoted | CommaSeparatedIteratorState::QuotedPair => { CommaSeparatedIteratorState::Quoted | CommaSeparatedIteratorState::QuotedPair => {
@ -173,7 +170,7 @@ impl<'a> Iterator for CommaSeparatedIterator<'a> {
self.state = CommaSeparatedIteratorState::Default; self.state = CommaSeparatedIteratorState::Default;
Some(&self.target[self.s..]) Some(&self.target[self.s..])
} }
}; }
} }
} }
@ -210,7 +207,7 @@ fn maybe_quoted(x: &str) -> Cow<str> {
} }
fn maybe_bracketed(x: &str) -> &str { fn maybe_bracketed(x: &str) -> &str {
if x.as_bytes()[0] == ('[' as u8) && x.as_bytes()[x.len() - 1] == (']' as u8) { if x.as_bytes()[0] == (b'[') && x.as_bytes()[x.len() - 1] == (b']') {
&x[1..x.len() - 1] &x[1..x.len() - 1]
} else { } else {
x x