Skip to content

Commit ad2c8cf

Browse files
committed
clippy
1 parent 85a6c95 commit ad2c8cf

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

postgres-protocol/src/types/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ fn write_pascal_string(s: &str, buf: &mut BytesMut) -> Result<(), StdBox<dyn Err
231231

232232
/// Deserializes an `HSTORE` value.
233233
#[inline]
234-
pub fn hstore_from_sql<'a>(
235-
mut buf: &'a [u8],
236-
) -> Result<HstoreEntries<'a>, StdBox<dyn Error + Sync + Send>> {
234+
pub fn hstore_from_sql(
235+
mut buf: &[u8],
236+
) -> Result<HstoreEntries<'_>, StdBox<dyn Error + Sync + Send>> {
237237
let count = buf.read_i32::<BigEndian>()?;
238238
if count < 0 {
239239
return Err("invalid entry count".into());
@@ -319,9 +319,7 @@ where
319319

320320
/// Deserializes a `VARBIT` or `BIT` value.
321321
#[inline]
322-
pub fn varbit_from_sql<'a>(
323-
mut buf: &'a [u8],
324-
) -> Result<Varbit<'a>, StdBox<dyn Error + Sync + Send>> {
322+
pub fn varbit_from_sql(mut buf: &[u8]) -> Result<Varbit<'_>, StdBox<dyn Error + Sync + Send>> {
325323
let len = buf.read_i32::<BigEndian>()?;
326324
if len < 0 {
327325
return Err("invalid varbit length: varbit < 0".into());
@@ -508,7 +506,7 @@ where
508506

509507
/// Deserializes an array value.
510508
#[inline]
511-
pub fn array_from_sql<'a>(mut buf: &'a [u8]) -> Result<Array<'a>, StdBox<dyn Error + Sync + Send>> {
509+
pub fn array_from_sql(mut buf: &[u8]) -> Result<Array<'_>, StdBox<dyn Error + Sync + Send>> {
512510
let dimensions = buf.read_i32::<BigEndian>()?;
513511
if dimensions < 0 {
514512
return Err("invalid dimension count".into());
@@ -738,7 +736,7 @@ pub enum RangeBound<T> {
738736

739737
/// Deserializes a range value.
740738
#[inline]
741-
pub fn range_from_sql<'a>(mut buf: &'a [u8]) -> Result<Range<'a>, StdBox<dyn Error + Sync + Send>> {
739+
pub fn range_from_sql(mut buf: &[u8]) -> Result<Range<'_>, StdBox<dyn Error + Sync + Send>> {
742740
let tag = buf.read_u8()?;
743741

744742
if tag == RANGE_EMPTY {
@@ -911,7 +909,7 @@ where
911909

912910
/// Deserializes a Postgres path.
913911
#[inline]
914-
pub fn path_from_sql<'a>(mut buf: &'a [u8]) -> Result<Path<'a>, StdBox<dyn Error + Sync + Send>> {
912+
pub fn path_from_sql(mut buf: &[u8]) -> Result<Path<'_>, StdBox<dyn Error + Sync + Send>> {
915913
let closed = buf.read_u8()? != 0;
916914
let points = buf.read_i32::<BigEndian>()?;
917915

tokio-postgres/src/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ impl<'a> UrlParser<'a> {
760760

761761
fn remove_url_prefix(s: &str) -> Option<&str> {
762762
for prefix in &["postgres://", "postgresql://"] {
763-
if s.starts_with(prefix) {
764-
return Some(&s[prefix.len()..]);
763+
if let Some(stripped) = s.strip_prefix(prefix) {
764+
return Some(stripped);
765765
}
766766
}
767767

@@ -825,8 +825,8 @@ impl<'a> UrlParser<'a> {
825825

826826
let host = &chunk[1..idx];
827827
let remaining = &chunk[idx + 1..];
828-
let port = if remaining.starts_with(':') {
829-
Some(&remaining[1..])
828+
let port = if let Some(port) = remaining.strip_prefix(':') {
829+
Some(port)
830830
} else if remaining.is_empty() {
831831
None
832832
} else {

tokio-postgres/src/connection.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,10 @@ where
200200
return Ok(false);
201201
}
202202

203-
if let Poll::Pending = Pin::new(&mut self.stream)
203+
if Pin::new(&mut self.stream)
204204
.poll_ready(cx)
205205
.map_err(Error::io)?
206+
.is_pending()
206207
{
207208
trace!("poll_write: waiting on socket");
208209
return Ok(false);

tokio-postgres/tests/test/types/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,7 @@ async fn domain() {
483483
}
484484

485485
fn accepts(ty: &Type) -> bool {
486-
ty.name() == "session_id"
487-
&& match *ty.kind() {
488-
Kind::Domain(_) => true,
489-
_ => false,
490-
}
486+
ty.name() == "session_id" && matches!(ty.kind(), Kind::Domain(_))
491487
}
492488

493489
to_sql_checked!();

0 commit comments

Comments
 (0)