Function find_node

Source
fn find_node<T, F>(node: SyntaxNode, f: F) -> Option<T>
where F: FnMut(SyntaxNode) -> Option<T>,
Expand description

@brief Helper function to find the first matching AST node.

This function traverses the syntax tree in preorder and applies the provided closure to each node, returning the first non-None result.

@tparam T The type returned by the closure. @tparam F The closure type, which takes a SyntaxNode and returns Option<T>. @param node The root SyntaxNode to start traversal from. @param f The closure to apply to each node. @return Option<T> The first non-None result from the closure, or None if not found.