identity-macro 0.1.0

Remove metavariable fragment to make it reusable for macro_rules
Documentation
#![doc = include_str!("../README.md")]
use proc_macro::{Group, TokenStream, TokenTree};

#[doc = include_str!("../README.md")]
#[proc_macro]
pub fn identity(stream: TokenStream) -> TokenStream {
    stream.into_iter().map(|tt| match tt {
        // NOTE: This is important, not just for recursion
        TokenTree::Group(g) => {
            let mut new_g = Group::new(g.delimiter(), identity(g.stream()));
            new_g.set_span(g.span());
            new_g.into()
        },
        _ => tt,
    }).collect()
}

/// Like [`identity`], But only handle the content inside `#identity(...)`
#[proc_macro]
pub fn identity_inner(stream: TokenStream) -> TokenStream {
    proc_macro_tool::pfunc_lossless(stream, false, ["identity"], |_, param| {
        identity(param.stream())
    })
}