INNER CODE UNIT · Rust

discard_punct_spans_stream

intellij-rust/intellij-rust · testData/test-proc-macros/src/lib.rs:192

fn discard_punct_spans_stream(ts: TokenStream) -> TokenStream {
    ts.into_iter().map(discard_punct_spans_tree).collect()
}

fn  discard_punct_spans_tree(tt: TokenTree) -> TokenTree {
    match tt {
        TokenTree::Group(g) => {
            let dg = Group::new(g.delimiter(), discard_punct_spans_stream(g.stream()));
            TokenTree::Group(dg)
        }
        TokenTree::Punct(p) => {
            TokenTree::Punct(Punct::new(p.as_char(), p.spacing()))
        }
        TokenTree::Ident(..) | TokenTree::Literal(..) => tt,
    }
}

/// Expands to `compile_error!("the error message")` attached to the first 3 tokens of the item

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…