fn max_id(subtree: &tt::Subtree) -> Option<u32> {
            subtree
                .token_trees
                .iter()
                .filter_map(|tt| match tt {
                    tt::TokenTree::Subtree(subtree) => {
                        let tree_id = max_id(subtree);
                        match subtree.delimiter {
                            Some(it) if it.id != tt::TokenId::unspecified() => {
                                Some(tree_id.map_or(it.id.0, |t| t.max(it.id.0)))
                            }
                            _ => tree_id,
                        }
                    }
                    tt::TokenTree::Leaf(tt::Leaf::Ident(ident))
                        if ident.id != tt::TokenId::unspecified() =>
                    {
                        Some(ident.id.0)
                    }
                    _ => None,
                })
                .max()
        }
// Find the max token id inside a subtree
Find the max token id inside a subtree
Find the max token id inside a subtree
fn max_id(subtree: &tt::Subtree) -> Option<u32> {
            subtree
                .token_trees
                .iter()
                .filter_map(|tt| match tt {
                    tt::TokenTree::Subtree(subtree) => {
                        let tree_id = max_id(subtree);
                        match subtree.delimiter {
                            Some(it) if it.id != tt::TokenId::unspecified() => {
                                Some(tree_id.map_or(it.id.0, |t| t.max(it.id.0)))
                            }
                            _ => tree_id,
                        }
                    }
                    tt::TokenTree::Leaf(tt::Leaf::Ident(ident))
                        if ident.id != tt::TokenId::unspecified() =>
                    {
                        Some(ident.id.0)
                    }
                    _ => None,
                })
                .max()
        }
fn max_id ( subtree : & tt :: Subtree ) -> Option < u32 > { subtree . token_trees . iter ( ) . filter_map ( | tt | match tt { tt :: TokenTree :: Subtree ( subtree ) => { let tree_id = max_id ( subtree ) ; match subtree . delimiter { Some ( it ) if it . id != tt :: TokenId :: unspecified ( ) => { Some ( tree_id . map_or ( it . id . 0 , | t | t . max ( it . id . 0 ) ) ) } _ => tree_id , } } tt :: TokenTree :: Leaf ( tt :: Leaf :: Ident ( ident ) ) if ident . id != tt :: TokenId :: unspecified ( ) => { Some ( ident . id . 0 ) } _ => None , } ) . max ( ) }
Find the max token id inside a subtree
Find the max token id inside a subtree
subtree
&tt::Subtree