Skip to main content

with_parser

Function with_parser 

Source
pub fn with_parser<F, R>(f: F) -> Result<R, TreeSitterError>
where F: FnOnce(&mut RustParser) -> R,
Expand description

Execute function with pooled parser instance.

On first call per thread, creates new parser. Subsequent calls reuse the same parser instance, avoiding allocation and initialization overhead.

ยงExample

use codex_patcher::pool::with_parser;

let result = with_parser(|parser| {
    parser.parse_with_source("fn main() {}")
})?;