fix clippy

This commit is contained in:
Steven Fackler 2020-10-15 21:14:13 -04:00
parent 510062238d
commit d1f9d6d802
4 changed files with 8 additions and 32 deletions

View File

@ -136,10 +136,7 @@ impl<'a> DatParser<'a> {
fn peek(&mut self, target: char) -> bool {
self.skip_ws();
match self.it.peek() {
Some((_, ch)) if *ch == target => true,
_ => false,
}
matches!(self.it.peek(), Some((_, ch)) if *ch == target)
}
fn eof(&mut self) {

View File

@ -330,10 +330,7 @@ impl<'a> Parser<'a> {
}
fn printable(&mut self) -> io::Result<&'a str> {
self.take_while(|c| match c {
'\x21'..='\x2b' | '\x2d'..='\x7e' => true,
_ => false,
})
self.take_while(|c| matches!(c, '\x21'..='\x2b' | '\x2d'..='\x7e'))
}
fn nonce(&mut self) -> io::Result<&'a str> {
@ -343,10 +340,7 @@ impl<'a> Parser<'a> {
}
fn base64(&mut self) -> io::Result<&'a str> {
self.take_while(|c| match c {
'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '=' => true,
_ => false,
})
self.take_while(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '='))
}
fn salt(&mut self) -> io::Result<&'a str> {
@ -356,10 +350,7 @@ impl<'a> Parser<'a> {
}
fn posit_number(&mut self) -> io::Result<u32> {
let n = self.take_while(|c| match c {
'0'..='9' => true,
_ => false,
})?;
let n = self.take_while(|c| matches!(c, '0'..='9'))?;
n.parse()
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))
}
@ -396,10 +387,7 @@ impl<'a> Parser<'a> {
}
fn value(&mut self) -> io::Result<&'a str> {
self.take_while(|c| match c {
'\0' | '=' | ',' => false,
_ => true,
})
self.take_while(|c| matches!(c, '\0' | '=' | ','))
}
fn server_error(&mut self) -> io::Result<Option<&'a str>> {

View File

@ -144,10 +144,7 @@ const NSEC_PER_USEC: u64 = 1_000;
macro_rules! accepts {
($($expected:ident),+) => (
fn accepts(ty: &$crate::Type) -> bool {
match *ty {
$($crate::Type::$expected)|+ => true,
_ => false
}
matches!(*ty, $($crate::Type::$expected)|+)
}
)
}

View File

@ -75,10 +75,7 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for Timestamp<T> {
}
fn accepts(ty: &Type) -> bool {
match *ty {
Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true,
_ => false,
}
matches!(*ty, Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty))
}
}
@ -99,10 +96,7 @@ impl<T: ToSql> ToSql for Timestamp<T> {
}
fn accepts(ty: &Type) -> bool {
match *ty {
Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true,
_ => false,
}
matches!(*ty, Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty))
}
to_sql_checked!();