pub fn flatten_tts(tts: &[TokenTree]) -> Vec<Spanned<String>> {
    tts.iter().flat_map(|tt| {
        match tt {
            &TokenTree::Token(span, ref tok) => {
                vec![respan(span, token_to_string(tok))]
            }
            &TokenTree::Delimited(_, ref delimited) => {
                let open = respan(delimited.open_span, token_to_string(&delimited.open_token()));
                let close = respan(delimited.close_span, token_to_string(&delimited.close_token()));

                iter::once(open)
                    .chain(flatten_tts(&delimited.tts))
                    .chain(iter::once(close))
                    .collect()
            }
            &TokenTree::Sequence(..) => unimplemented!()
        }
    }).collect()
}
/// Flatten a token tree stream.
///
/// Each token is stringified and paired with it's span.
Flatten a token tree stream.
Each token is stringified and paired with it's span.
Flatten a token tree stream . Each token is stringified and paired with it ' s span .
pub fn flatten_tts(tts: &[TokenTree]) -> Vec<Spanned<String>> {
    tts.iter().flat_map(|tt| {
        match tt {
            &TokenTree::Token(span, ref tok) => {
                vec![respan(span, token_to_string(tok))]
            }
            &TokenTree::Delimited(_, ref delimited) => {
                let open = respan(delimited.open_span, token_to_string(&delimited.open_token()));
                let close = respan(delimited.close_span, token_to_string(&delimited.close_token()));
                iter::once(open)
                    .chain(flatten_tts(&delimited.tts))
                    .chain(iter::once(close))
                    .collect()
            }
            &TokenTree::Sequence(..) => unimplemented!()
        }
    }).collect()
}
pub fn flatten_tts ( tts : & [ TokenTree ] ) -> Vec < Spanned < String > > { tts . iter ( ) . flat_map ( | tt | { match tt { & TokenTree :: Token ( span , ref tok ) => { vec ! [ respan ( span token_to_string ( tok ) ) ] } & TokenTree :: Delimited ( _ , ref delimited ) => { let open = respan ( delimited . open_span , token_to_string ( & delimited . open_token ( ) ) ) ; let close = respan ( delimited . close_span , token_to_string ( & delimited . close_token ( ) ) ) ; iter :: once ( open ) . chain ( flatten_tts ( & delimited . tts ) ) . chain ( iter :: once ( close ) ) . collect ( ) } & TokenTree :: Sequence ( .. ) => unimplemented ! ( ) } } ) . collect ( ) }
Flatten a token tree stream.
Flatten a token tree stream .
tts
&[TokenTree]
tts
&[TokenTree]