1+ use std:: error:: Error ;
12use std:: fmt:: { Debug , Display } ;
23use std:: marker:: PhantomData ;
34use std:: str:: FromStr ;
@@ -21,7 +22,6 @@ impl<Rep, Tag> Tagged<Rep, Tag> {
2122 {
2223 rep. refine ( ) . map ( |rep| Tagged ( rep, PhantomData ) )
2324 }
24-
2525 pub fn rep ( & self ) -> & Rep {
2626 & self . 0
2727 }
@@ -123,15 +123,14 @@ mod diesel_impl {
123123 use diesel:: deserialize:: FromSql ;
124124 use diesel:: expression:: AsExpression ;
125125 use diesel:: serialize:: { Output , ToSql } ;
126- use diesel:: sql_types:: { SingleValue , SqlType } ;
126+ use diesel:: sql_types:: SingleValue ;
127127
128128 impl < Rep , Tag , ST > AsExpression < ST > for Tagged < Rep , Tag >
129129 where
130130 Rep : Clone + AsExpression < ST > ,
131- ST : SqlType + SingleValue ,
131+ ST : SingleValue ,
132132 {
133- type Expression =
134- <Rep as AsExpression < ST > >:: Expression ;
133+ type Expression = Rep :: Expression ;
135134 fn as_expression ( self ) -> Self :: Expression {
136135 self . rep ( ) . clone ( ) . as_expression ( )
137136 }
@@ -140,10 +139,9 @@ mod diesel_impl {
140139 impl < Rep , Tag , ST > AsExpression < ST > for & Tagged < Rep , Tag >
141140 where
142141 Rep : Clone + AsExpression < ST > ,
143- ST : SqlType + SingleValue ,
142+ ST : SingleValue ,
144143 {
145- type Expression =
146- <Rep as AsExpression < ST > >:: Expression ;
144+ type Expression = Rep :: Expression ;
147145 fn as_expression ( self ) -> Self :: Expression {
148146 self . rep ( ) . clone ( ) . as_expression ( )
149147 }
@@ -152,7 +150,6 @@ mod diesel_impl {
152150 impl < DB , Rep , Tag , ST > ToSql < ST , DB > for Tagged < Rep , Tag >
153151 where
154152 Rep : ToSql < ST , DB > ,
155- ST : SqlType + SingleValue ,
156153 DB : Backend ,
157154 Tag : Debug ,
158155 {
@@ -167,37 +164,30 @@ mod diesel_impl {
167164 impl < DB , Rep , Tag , ST > FromSql < ST , DB > for Tagged < Rep , Tag >
168165 where
169166 Rep : FromSql < ST , DB > + Refine < Tag > ,
170- Rep :: RefineError : Display ,
171- ST : SqlType + SingleValue ,
167+ Rep :: RefineError : ' static + Error + Send + Sync ,
172168 DB : Backend ,
173169 {
174170 fn from_sql (
175171 bytes : DB :: RawValue < ' _ > ,
176172 ) -> diesel:: deserialize:: Result < Self > {
177173 let rep = Rep :: from_sql ( bytes) ?;
178- Tagged :: new ( rep) . map_err ( |e| {
179- format ! ( "Refine failed: {e}" ) . into ( )
180- } )
174+ Ok ( Tagged :: new ( rep) . map_err ( Box :: new) ?)
181175 }
182176 }
183177
184178 impl < Rep , Tag , ST , DB > Queryable < ST , DB >
185179 for Tagged < Rep , Tag >
186180 where
187181 Rep : Queryable < ST , DB > + Refine < Tag > ,
188- Rep :: RefineError : Display ,
189- ST : SqlType + SingleValue ,
182+ Rep :: RefineError : ' static + Error + Send + Sync ,
190183 DB : Backend ,
191184 {
192- type Row = < Rep as Queryable < ST , DB > > :: Row ;
185+ type Row = Rep :: Row ;
193186 fn build (
194187 row : Self :: Row ,
195188 ) -> diesel:: deserialize:: Result < Self > {
196- let rep =
197- <Rep as Queryable < ST , DB > >:: build ( row) ?;
198- Tagged :: new ( rep) . map_err ( |e| {
199- format ! ( "Refine failed: {e}" ) . into ( )
200- } )
189+ let rep = Queryable :: build ( row) ?;
190+ Ok ( Tagged :: new ( rep) . map_err ( Box :: new) ?)
201191 }
202192 }
203193}
0 commit comments