diff --git a/postgres-protocol/src/types/mod.rs b/postgres-protocol/src/types/mod.rs index 436132c2..a595f5a3 100644 --- a/postgres-protocol/src/types/mod.rs +++ b/postgres-protocol/src/types/mod.rs @@ -231,9 +231,9 @@ fn write_pascal_string(s: &str, buf: &mut BytesMut) -> Result<(), StdBox( - mut buf: &'a [u8], -) -> Result, StdBox> { +pub fn hstore_from_sql( + mut buf: &[u8], +) -> Result, StdBox> { let count = buf.read_i32::()?; if count < 0 { return Err("invalid entry count".into()); @@ -319,9 +319,7 @@ where /// Deserializes a `VARBIT` or `BIT` value. #[inline] -pub fn varbit_from_sql<'a>( - mut buf: &'a [u8], -) -> Result, StdBox> { +pub fn varbit_from_sql(mut buf: &[u8]) -> Result, StdBox> { let len = buf.read_i32::()?; if len < 0 { return Err("invalid varbit length: varbit < 0".into()); @@ -508,7 +506,7 @@ where /// Deserializes an array value. #[inline] -pub fn array_from_sql<'a>(mut buf: &'a [u8]) -> Result, StdBox> { +pub fn array_from_sql(mut buf: &[u8]) -> Result, StdBox> { let dimensions = buf.read_i32::()?; if dimensions < 0 { return Err("invalid dimension count".into()); @@ -738,7 +736,7 @@ pub enum RangeBound { /// Deserializes a range value. #[inline] -pub fn range_from_sql<'a>(mut buf: &'a [u8]) -> Result, StdBox> { +pub fn range_from_sql(mut buf: &[u8]) -> Result, StdBox> { let tag = buf.read_u8()?; if tag == RANGE_EMPTY { @@ -911,7 +909,7 @@ where /// Deserializes a Postgres path. #[inline] -pub fn path_from_sql<'a>(mut buf: &'a [u8]) -> Result, StdBox> { +pub fn path_from_sql(mut buf: &[u8]) -> Result, StdBox> { let closed = buf.read_u8()? != 0; let points = buf.read_i32::()?; diff --git a/tokio-postgres/src/config.rs b/tokio-postgres/src/config.rs index da171cc7..11148717 100644 --- a/tokio-postgres/src/config.rs +++ b/tokio-postgres/src/config.rs @@ -760,8 +760,8 @@ impl<'a> UrlParser<'a> { fn remove_url_prefix(s: &str) -> Option<&str> { for prefix in &["postgres://", "postgresql://"] { - if s.starts_with(prefix) { - return Some(&s[prefix.len()..]); + if let Some(stripped) = s.strip_prefix(prefix) { + return Some(stripped); } } @@ -825,8 +825,8 @@ impl<'a> UrlParser<'a> { let host = &chunk[1..idx]; let remaining = &chunk[idx + 1..]; - let port = if remaining.starts_with(':') { - Some(&remaining[1..]) + let port = if let Some(port) = remaining.strip_prefix(':') { + Some(port) } else if remaining.is_empty() { None } else { diff --git a/tokio-postgres/src/connection.rs b/tokio-postgres/src/connection.rs index 9c8e369f..b6805f76 100644 --- a/tokio-postgres/src/connection.rs +++ b/tokio-postgres/src/connection.rs @@ -200,9 +200,10 @@ where return Ok(false); } - if let Poll::Pending = Pin::new(&mut self.stream) + if Pin::new(&mut self.stream) .poll_ready(cx) .map_err(Error::io)? + .is_pending() { trace!("poll_write: waiting on socket"); return Ok(false); diff --git a/tokio-postgres/tests/test/types/mod.rs b/tokio-postgres/tests/test/types/mod.rs index 11d12876..bc31ece7 100644 --- a/tokio-postgres/tests/test/types/mod.rs +++ b/tokio-postgres/tests/test/types/mod.rs @@ -483,11 +483,7 @@ async fn domain() { } fn accepts(ty: &Type) -> bool { - ty.name() == "session_id" - && match *ty.kind() { - Kind::Domain(_) => true, - _ => false, - } + ty.name() == "session_id" && matches!(ty.kind(), Kind::Domain(_)) } to_sql_checked!();