Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Oct 16, 2020
1 parent 5100622 commit d1f9d6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
5 changes: 1 addition & 4 deletions codegen/src/type_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 4 additions & 16 deletions postgres-protocol/src/authentication/sasl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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> {
Expand All @@ -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))
}
Expand Down Expand Up @@ -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>> {
Expand Down
5 changes: 1 addition & 4 deletions postgres-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)|+)
}
)
}
Expand Down
10 changes: 2 additions & 8 deletions postgres-types/src/special.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand All @@ -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!();
Expand Down

0 comments on commit d1f9d6d

Please sign in to comment.