macro
TokenTree and nested groups
A delimited group contains its own stream. Inspect that stream to count direct children; nested groups are not flattened automatically. Example: two-crate workspace; see fixtures/proc-macro-workspace/consumer/src/bin/token_tree.rs. This caller is not a standalone rustc program. Expected stdout (not executed): '3\n' Common mistake: Counting the opening and closing parentheses as separate top-level tokens.
Formal Syntax & Structure
rust syntaxrust
TokenTree::Group(group)Working Example
Example Snippetrust
use teaching_macros::group_count;fn main() { println!("{}", group_count!((1, 2))); }