wiwi_macro_proc/
with_cloned.rs1use proc_macro2::{ Spacing, Span, TokenStream, TokenTree };
3use syn::Error;
5pub fn with_cloned(input: TokenStream) -> Result<TokenStream, TokenStream> {
8 let mut iter = input.into_iter();
9
10 loop {
11 match iter.next() {
12 Some(TokenTree::Ident(ident)) => {
13 match &*ident.to_string() {
14 "_" => {
15 match iter.next() {
16 Some(TokenTree::Punct(punct)) if punct.as_char() == '=' && punct.spacing() == Spacing::Joint => { }
17 Some(tt) => {
18 return Err(Error::new_spanned(tt, "unexpected token").into_compile_error())
19 }
20 None => {
21 return Err(Error::new(Span::call_site(), "unexpected end of macro input").into_compile_error())
22 }
23 }
24 match iter.next() {
25 Some(TokenTree::Punct(punct)) if punct.as_char() == '>' && punct.spacing() == Spacing::Alone => { }
26 Some(tt) => {
27 return Err(Error::new_spanned(tt, "unexpected token").into_compile_error())
28 }
29 None => {
30 return Err(Error::new(Span::call_site(), "unexpected end of macro input").into_compile_error())
31 }
32 }
33 }
34 "mut" => {
35 }
36 _ident => {}
37 }
38 }
40
41 Some(TokenTree::Group(_group)) => {}
42
43 Some(TokenTree::Punct(_punct)) => {
44 }
49
50 Some(TokenTree::Literal(_literal)) => {
51 }
56
57 None => {
58 return Err(Error::new(
59 Span::call_site(),
60 "unexpected end of macro invocation"
61 ).into_compile_error())
62 }
63 }
64 }
65}