Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Mar 17, 2021
1 parent 85a6c95 commit ad2c8cf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
16 changes: 7 additions & 9 deletions postgres-protocol/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ fn write_pascal_string(s: &str, buf: &mut BytesMut) -> Result<(), StdBox<dyn Err

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

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

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

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

if tag == RANGE_EMPTY {
Expand Down Expand Up @@ -911,7 +909,7 @@ where

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

Expand Down
8 changes: 4 additions & 4 deletions tokio-postgres/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion tokio-postgres/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions tokio-postgres/tests/test/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!();
Expand Down

0 comments on commit ad2c8cf

Please sign in to comment.