File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 108
108
#![ doc( html_root_url = "https://docs.rs/postgres-types/0.1" ) ]
109
109
#![ warn( clippy:: all, rust_2018_idioms, missing_docs) ]
110
110
111
- use crate :: sealed:: Sealed ;
112
111
use fallible_iterator:: FallibleIterator ;
113
112
use postgres_protocol:: types:: { self , ArrayDimension } ;
114
113
use std:: any:: type_name;
@@ -957,26 +956,30 @@ mod sealed {
957
956
pub trait Sealed { }
958
957
}
959
958
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`.
962
960
///
963
961
/// This cannot be implemented outside of this crate.
964
962
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.
966
964
fn borrow_to_sql ( & self ) -> & dyn ToSql ;
967
965
}
968
966
969
- impl Sealed for & dyn ToSql { }
967
+ impl sealed :: Sealed for & dyn ToSql { }
970
968
971
969
impl BorrowToSql for & dyn ToSql {
970
+ #[ inline]
972
971
fn borrow_to_sql ( & self ) -> & dyn ToSql {
973
972
* self
974
973
}
975
974
}
976
975
977
- impl < T : ToSql > Sealed for T { }
976
+ impl < T > sealed :: Sealed for T where T : ToSql { }
978
977
979
- impl < T : ToSql > BorrowToSql for T {
978
+ impl < T > BorrowToSql for T
979
+ where
980
+ T : ToSql ,
981
+ {
982
+ #[ inline]
980
983
fn borrow_to_sql ( & self ) -> & dyn ToSql {
981
984
self
982
985
}
Original file line number Diff line number Diff line change @@ -14,8 +14,12 @@ use std::marker::PhantomPinned;
14
14
use std:: pin:: Pin ;
15
15
use std:: task:: { Context , Poll } ;
16
16
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
+ {
19
23
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
20
24
f. debug_list ( )
21
25
. entries ( self . 0 . iter ( ) . map ( |x| x. borrow_to_sql ( ) ) )
You can’t perform that action at this time.
0 commit comments