Skip to content

Commit d1f9d6d

Browse files
committed
fix clippy
1 parent 5100622 commit d1f9d6d

File tree

4 files changed

+8
-32
lines changed

4 files changed

+8
-32
lines changed

codegen/src/type_gen.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ impl<'a> DatParser<'a> {
136136
fn peek(&mut self, target: char) -> bool {
137137
self.skip_ws();
138138

139-
match self.it.peek() {
140-
Some((_, ch)) if *ch == target => true,
141-
_ => false,
142-
}
139+
matches!(self.it.peek(), Some((_, ch)) if *ch == target)
143140
}
144141

145142
fn eof(&mut self) {

postgres-protocol/src/authentication/sasl.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,7 @@ impl<'a> Parser<'a> {
330330
}
331331

332332
fn printable(&mut self) -> io::Result<&'a str> {
333-
self.take_while(|c| match c {
334-
'\x21'..='\x2b' | '\x2d'..='\x7e' => true,
335-
_ => false,
336-
})
333+
self.take_while(|c| matches!(c, '\x21'..='\x2b' | '\x2d'..='\x7e'))
337334
}
338335

339336
fn nonce(&mut self) -> io::Result<&'a str> {
@@ -343,10 +340,7 @@ impl<'a> Parser<'a> {
343340
}
344341

345342
fn base64(&mut self) -> io::Result<&'a str> {
346-
self.take_while(|c| match c {
347-
'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '=' => true,
348-
_ => false,
349-
})
343+
self.take_while(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '='))
350344
}
351345

352346
fn salt(&mut self) -> io::Result<&'a str> {
@@ -356,10 +350,7 @@ impl<'a> Parser<'a> {
356350
}
357351

358352
fn posit_number(&mut self) -> io::Result<u32> {
359-
let n = self.take_while(|c| match c {
360-
'0'..='9' => true,
361-
_ => false,
362-
})?;
353+
let n = self.take_while(|c| matches!(c, '0'..='9'))?;
363354
n.parse()
364355
.map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))
365356
}
@@ -396,10 +387,7 @@ impl<'a> Parser<'a> {
396387
}
397388

398389
fn value(&mut self) -> io::Result<&'a str> {
399-
self.take_while(|c| match c {
400-
'\0' | '=' | ',' => false,
401-
_ => true,
402-
})
390+
self.take_while(|c| matches!(c, '\0' | '=' | ','))
403391
}
404392

405393
fn server_error(&mut self) -> io::Result<Option<&'a str>> {

postgres-types/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ const NSEC_PER_USEC: u64 = 1_000;
144144
macro_rules! accepts {
145145
($($expected:ident),+) => (
146146
fn accepts(ty: &$crate::Type) -> bool {
147-
match *ty {
148-
$($crate::Type::$expected)|+ => true,
149-
_ => false
150-
}
147+
matches!(*ty, $($crate::Type::$expected)|+)
151148
}
152149
)
153150
}

postgres-types/src/special.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for Timestamp<T> {
7575
}
7676

7777
fn accepts(ty: &Type) -> bool {
78-
match *ty {
79-
Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true,
80-
_ => false,
81-
}
78+
matches!(*ty, Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty))
8279
}
8380
}
8481

@@ -99,10 +96,7 @@ impl<T: ToSql> ToSql for Timestamp<T> {
9996
}
10097

10198
fn accepts(ty: &Type) -> bool {
102-
match *ty {
103-
Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true,
104-
_ => false,
105-
}
99+
matches!(*ty, Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty))
106100
}
107101

108102
to_sql_checked!();

0 commit comments

Comments
 (0)