pub fn parse_sources<R: Send>(
inputs: Vec<(RelPath, String)>,
options: &LoadOptions,
visit: impl FnOnce(Vec<ParsedSource>) -> R + Send,
) -> Result<R, LoadError>Expand description
Parse an explicit corpus once and give all its syntax trees to one visitor.
Input order and identities are preserved, including repeated identities.
Before parsing any file, the complete input is checked against
options.max_file_bytes, options.max_total_bytes, options.max_file_tokens
and the native recursion budgets. The result-vector allocation is charged to
options.max_item_bytes. This bounds source input and corpus-container storage;
it does not meter the aggregate heap of retained syn trees or allocations
made by visit. Each file retains the parser’s per-file resource bounds.
Parsing, visiting and dropping the trees run on one scoped worker with
PARSE_STACK_BYTES. The visitor runs exactly once, after every file parses,
including for an empty corpus. Only its Send result leaves the worker.
A visitor returning a Result retains its own typed error in that result.
No filesystem, Cargo, target selection or duplicate policy is involved.
§Errors
Returns the native LoadError naming the input that exceeded a limit or
failed to parse. Worker startup and corpus-vector allocation failures are
also errors. No failed corpus reaches the visitor as a partial success.
§Panics
A parser or visitor panic resumes on the caller with its original payload.