Skip to content

Commit bbf3169

Browse files
committed
Cleanups
1 parent 1fcd04d commit bbf3169

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

postgres-types/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
#![doc(html_root_url = "https://docs.rs/postgres-types/0.1")]
109109
#![warn(clippy::all, rust_2018_idioms, missing_docs)]
110110

111-
use crate::sealed::Sealed;
112111
use fallible_iterator::FallibleIterator;
113112
use postgres_protocol::types::{self, ArrayDimension};
114113
use std::any::type_name;
@@ -957,26 +956,30 @@ mod sealed {
957956
pub trait Sealed {}
958957
}
959958

960-
/// A helper trait used internally by Rust-Postgres
961-
/// to be able create a parameters iterator from `&dyn ToSql` or `T: ToSql`.
959+
/// A trait used by clients to abstract over `&dyn ToSql` and `T: ToSql`.
962960
///
963961
/// This cannot be implemented outside of this crate.
964962
pub trait BorrowToSql: sealed::Sealed {
965-
/// Get a reference to a `ToSql` trait object
963+
/// Returns a reference to `self` as a `ToSql` trait object.
966964
fn borrow_to_sql(&self) -> &dyn ToSql;
967965
}
968966

969-
impl Sealed for &dyn ToSql {}
967+
impl sealed::Sealed for &dyn ToSql {}
970968

971969
impl BorrowToSql for &dyn ToSql {
970+
#[inline]
972971
fn borrow_to_sql(&self) -> &dyn ToSql {
973972
*self
974973
}
975974
}
976975

977-
impl<T: ToSql> Sealed for T {}
976+
impl<T> sealed::Sealed for T where T: ToSql {}
978977

979-
impl<T: ToSql> BorrowToSql for T {
978+
impl<T> BorrowToSql for T
979+
where
980+
T: ToSql,
981+
{
982+
#[inline]
980983
fn borrow_to_sql(&self) -> &dyn ToSql {
981984
self
982985
}

tokio-postgres/src/query.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ use std::marker::PhantomPinned;
1414
use std::pin::Pin;
1515
use std::task::{Context, Poll};
1616

17-
struct BorrowToSqlParamsDebug<'a, T: BorrowToSql>(&'a [T]);
18-
impl<'a, T: BorrowToSql> std::fmt::Debug for BorrowToSqlParamsDebug<'a, T> {
17+
struct BorrowToSqlParamsDebug<'a, T>(&'a [T]);
18+
19+
impl<'a, T> fmt::Debug for BorrowToSqlParamsDebug<'a, T>
20+
where
21+
T: BorrowToSql,
22+
{
1923
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2024
f.debug_list()
2125
.entries(self.0.iter().map(|x| x.borrow_to_sql()))

0 commit comments

Comments
 (0)