@@ -221,39 +221,21 @@ impl Attributes {
221
221
Ok ( result)
222
222
}
223
223
224
- pub ( crate ) fn needs_bounds_derive ( & self , ty : BoundType ) -> bool {
225
- let predicates = self . get_bounds ( ty) ;
224
+ pub ( crate ) fn needs_bounds_derive < const IS_ASYNC : bool > ( & self , ty : BoundType ) -> bool {
225
+ let predicates = self . get_bounds :: < IS_ASYNC > ( ty) ;
226
226
predicates. is_none ( )
227
227
}
228
228
229
- pub ( crate ) fn needs_async_bounds_derive ( & self , ty : BoundType ) -> bool {
230
- let predicates = self . get_async_bounds ( ty) ;
231
- predicates. is_none ( )
232
- }
233
-
234
- fn get_bounds ( & self , ty : BoundType ) -> Option < Vec < WherePredicate > > {
235
- let bounds = self . bounds . as_ref ( ) ;
236
- bounds. and_then ( |bounds| match ty {
237
- BoundType :: Serialize => bounds. serialize . clone ( ) ,
238
- BoundType :: Deserialize => bounds. deserialize . clone ( ) ,
239
- } )
240
- }
241
-
242
- fn get_async_bounds ( & self , ty : BoundType ) -> Option < Vec < WherePredicate > > {
243
- let bounds = self . async_bounds . as_ref ( ) ;
229
+ fn get_bounds < const IS_ASYNC : bool > ( & self , ty : BoundType ) -> Option < Vec < WherePredicate > > {
230
+ let bounds = if IS_ASYNC { self . async_bounds . as_ref ( ) } else { self . bounds . as_ref ( ) } ;
244
231
bounds. and_then ( |bounds| match ty {
245
232
BoundType :: Serialize => bounds. serialize . clone ( ) ,
246
233
BoundType :: Deserialize => bounds. deserialize . clone ( ) ,
247
234
} )
248
235
}
249
236
250
- pub ( crate ) fn collect_bounds ( & self , ty : BoundType ) -> Vec < WherePredicate > {
251
- let predicates = self . get_bounds ( ty) ;
252
- predicates. unwrap_or_default ( )
253
- }
254
-
255
- pub ( crate ) fn collect_async_bounds ( & self , ty : BoundType ) -> Vec < WherePredicate > {
256
- let predicates = self . get_async_bounds ( ty) ;
237
+ pub ( crate ) fn collect_bounds < const IS_ASYNC : bool > ( & self , ty : BoundType ) -> Vec < WherePredicate > {
238
+ let predicates = self . get_bounds :: < IS_ASYNC > ( ty) ;
257
239
predicates. unwrap_or_default ( )
258
240
}
259
241
}
0 commit comments