1use crate::utils::{add_where_clauses_for_new_ident, MultiFieldData, RefType};
2use proc_macro2::TokenStream;
3use quote::quote;
4use syn::{Generics, Ident};
5
6pub fn generics_and_exprs(
7 multi_field_data: MultiFieldData,
8 scalar_ident: &Ident,
9 type_where_clauses: TokenStream,
10 ref_type: RefType,
11) -> (Generics, Vec<TokenStream>) {
12 let MultiFieldData {
13 fields,
14 casted_traits,
15 members,
16 method_ident,
17 ..
18 } = multi_field_data;
19 let reference = ref_type.reference();
20 let exprs: Vec<_> = casted_traits
21 .iter()
22 .zip(members)
23 .map(
24 |(casted_trait, member)| quote!(#casted_trait::#method_ident(#reference #member, rhs)),
25 )
26 .collect();
27
28 let new_generics = add_where_clauses_for_new_ident(
29 &multi_field_data.state.input.generics,
30 &fields,
31 scalar_ident,
32 type_where_clauses,
33 true,
34 );
35 (new_generics, exprs)
36}
37