Skip to main content

parse_document_fast

Function parse_document_fast 

Source
pub fn parse_document_fast(source: &str) -> Option<Node>
Expand description

Try the cold-start fast path on source. Returns Some(Node) when the source fits the trivial-scalar #main envelope and a minimal Node was built; None for every other shape — caller should fall back to crate::parse_document.

Note on semantics: the returned Node is the same shape (expr + directives + range + doc_comment = None) the slow path produces for these inputs; the parameter / type / directive ranges match the byte offsets the slow path would emit, so the resulting Node round-trips through the analyzer and tree-walker without any divergence vs. parse_document.