pub fn split_out_externs(ast: &syn::ItemImpl) -> TokenStream {
    let mut tokens = TokenStream::new();
    tokens.append_all(ast.items.iter().filter_map(|item| {
        match item {
            syn::ImplItem::Method(iim) => {
                if iim.sig.abi.is_c(){
                    Some(item.into_token_stream())
                } else {
                    let mut ret = None;
                    for attr in iim.attrs.iter().filter_map(|a| a.interpret_meta()) {
                        match attr {
                            syn::Meta::List(ml) => if ml.ident == syn::Ident::new("swiggen", Span::call_site()) {
                                if let Some(v) = ml.nested.first().map(|p| p.into_value()) {
                                    match v {
                                        syn::NestedMeta::Meta(m) => {
                                            let base_name = Some(m.name());
                                            ret = Some(impl_extern_fn(&base_name, &iim_to_itemfn(iim.clone())));
                                        },
                                        _ => {}
                                    }
                                }
                            },
                            _ => {}
                        }
                    }
                    ret
                }
            },
            _ => None,
        }
    }));

    quote!{
        #ast

        #tokens
    }
}
/// Parse a Rust file to extract any extern "C" functions or
/// `#[swiggen]`-annotated methods and move these out of the impl block.
Parse a Rust file to extract any extern "C" functions or
`#[swiggen]`-annotated methods and move these out of the impl block.
Parse a Rust file to extract any extern " C " functions or ` # [ swiggen ] ` - annotated methods and move these out of the impl block .
pub fn split_out_externs(ast: &syn::ItemImpl) -> TokenStream {
    let mut tokens = TokenStream::new();
    tokens.append_all(ast.items.iter().filter_map(|item| {
        match item {
            syn::ImplItem::Method(iim) => {
                if iim.sig.abi.is_c(){
                    Some(item.into_token_stream())
                } else {
                    let mut ret = None;
                    for attr in iim.attrs.iter().filter_map(|a| a.interpret_meta()) {
                        match attr {
                            syn::Meta::List(ml) => if ml.ident == syn::Ident::new("swiggen", Span::call_site()) {
                                if let Some(v) = ml.nested.first().map(|p| p.into_value()) {
                                    match v {
                                        syn::NestedMeta::Meta(m) => {
                                            let base_name = Some(m.name());
                                            ret = Some(impl_extern_fn(&base_name, &iim_to_itemfn(iim.clone())));
                                        },
                                        _ => {}
                                    }
                                }
                            },
                            _ => {}
                        }
                    }
                    ret
                }
            },
            _ => None,
        }
    }));
    quote!{
        #ast
        #tokens
    }
}
pub fn split_out_externs ( ast : & syn :: ItemImpl ) -> TokenStream { let mut tokens = TokenStream :: new ( ) ; tokens . append_all ( ast . items . iter ( ) . filter_map ( | item | { match item { syn :: ImplItem :: Method ( iim ) => { if iim . sig . abi . is_c ( ) { Some ( item . into_token_stream ( ) ) } else { let mut ret = None ; for attr in iim . attrs . iter ( ) . filter_map ( | a | a . interpret_meta ( ) ) { match attr { syn :: Meta :: List ( ml ) => if ml . ident == syn :: Ident :: new ( " " , Span :: call_site ( ) ) { if let Some ( v ) = ml . nested . first ( ) . map ( | p | p . into_value ( ) ) { match v { syn :: NestedMeta :: Meta ( m ) => { let base_name = Some ( m . name ( ) ) ; ret = Some ( impl_extern_fn ( & base_name , & iim_to_itemfn ( iim . clone ( ) ) ) ) ; } , _ => { } } } } , _ => { } } } ret } } , _ => None , } } ) ) ; quote ! { ast tokens } }
Parse a Rust file to extract any extern "C" functions or
`#[swiggen]`-annotated methods and move these out of the impl block.
Parse a Rust file to extract any extern " C " functions or ` # [ swiggen ] ` - annotated methods and move these out of the impl block .
ast
&syn::ItemImpl
ast
&syn::ItemImpl