cgp-macro-lib 0.7.0

Context-generic programming core component macros implemented as a library.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use proc_macro2::Span;
use syn::{FnArg, Ident, Signature, parse_quote};

pub fn signature_to_args(sig: &Signature) -> impl Iterator<Item = Ident> + '_ {
    sig.inputs.iter().map(|arg| -> Ident {
        match arg {
            FnArg::Receiver(_) => Ident::new("self", Span::call_site()),
            FnArg::Typed(pat) => {
                let ident_pat = &pat.pat;
                parse_quote!( #ident_pat )
            }
        }
    })
}