This commit is contained in:
Steven Fackler 2021-03-16 20:32:26 -04:00
parent 85a6c95a69
commit ad2c8cf592
4 changed files with 14 additions and 19 deletions

View File

@ -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());
@ -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());
@ -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());
@ -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 {
@ -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>()?;

View File

@ -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 {

View File

@ -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);

View File

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