mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 07:21:12 +00:00
Eliminate generic functions in bound.rs
This commit is contained in:
parent
24700ebeb6
commit
00178ba795
@ -51,14 +51,11 @@ pub fn with_where_predicates(
|
|||||||
generics
|
generics
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_where_predicates_from_fields<F>(
|
pub fn with_where_predicates_from_fields(
|
||||||
cont: &Container,
|
cont: &Container,
|
||||||
generics: &syn::Generics,
|
generics: &syn::Generics,
|
||||||
from_field: F,
|
from_field: fn(&attr::Field) -> Option<&[syn::WherePredicate]>,
|
||||||
) -> syn::Generics
|
) -> syn::Generics {
|
||||||
where
|
|
||||||
F: Fn(&attr::Field) -> Option<&[syn::WherePredicate]>,
|
|
||||||
{
|
|
||||||
let predicates = cont.data
|
let predicates = cont.data
|
||||||
.all_fields()
|
.all_fields()
|
||||||
.flat_map(|field| from_field(&field.attrs))
|
.flat_map(|field| from_field(&field.attrs))
|
||||||
@ -82,15 +79,12 @@ where
|
|||||||
// #[serde(skip_serializing)]
|
// #[serde(skip_serializing)]
|
||||||
// c: C,
|
// c: C,
|
||||||
// }
|
// }
|
||||||
pub fn with_bound<F>(
|
pub fn with_bound(
|
||||||
cont: &Container,
|
cont: &Container,
|
||||||
generics: &syn::Generics,
|
generics: &syn::Generics,
|
||||||
filter: F,
|
filter: fn(&attr::Field, Option<&attr::Variant>) -> bool,
|
||||||
bound: &syn::Path,
|
bound: &syn::Path,
|
||||||
) -> syn::Generics
|
) -> syn::Generics {
|
||||||
where
|
|
||||||
F: Fn(&attr::Field, Option<&attr::Variant>) -> bool,
|
|
||||||
{
|
|
||||||
struct FindTyParams<'ast> {
|
struct FindTyParams<'ast> {
|
||||||
// Set of all generic type parameters on the current struct (A, B, C in
|
// Set of all generic type parameters on the current struct (A, B, C in
|
||||||
// the example). Initialized up front.
|
// the example). Initialized up front.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user