1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//! Provides common utils function shared between full and semi-automatic. use proc_macro2::TokenStream; use syn::{parse_quote, Generics, Ident}; use quote::quote; /// Add the given tuple elements as generics with the given `bounds` to `generics`. pub fn add_tuple_element_generics( tuple_elements: &[Ident], bounds: Option<TokenStream>, generics: &mut Generics, ) { let bound = bounds.map(|b| quote!(: #b)).unwrap_or_else(|| quote!()); tuple_elements.iter().for_each(|tuple_element| { generics.params.push(parse_quote!(#tuple_element #bound)); }); }