1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use crate::AccountsStruct; use quote::quote; mod __client_accounts; mod constraints; mod exit; mod to_account_infos; mod to_account_metas; mod try_accounts; pub fn generate(accs: &AccountsStruct) -> proc_macro2::TokenStream { let impl_try_accounts = try_accounts::generate(accs); let impl_to_account_infos = to_account_infos::generate(accs); let impl_to_account_metas = to_account_metas::generate(accs); let impl_exit = exit::generate(accs); let __client_accounts_mod = __client_accounts::generate(accs); quote! { #impl_try_accounts #impl_to_account_infos #impl_to_account_metas #impl_exit #__client_accounts_mod } } fn generics( accs: &AccountsStruct, ) -> ( proc_macro2::TokenStream, proc_macro2::TokenStream, proc_macro2::TokenStream, ) { match accs.generics.lt_token { None => (quote! {<'info>}, quote! {<'info>}, quote! {}), Some(_) => { let g = &accs.generics; (quote! {#g}, quote! {#g}, quote! {#g}) } } }