pub fn process_file_with_context<T, F>(
path: &Path,
parent_ctx: &ParallelContext,
f: F,
) -> Twhere
F: FnOnce() -> T,Expand description
Process a file with full context setup.
This combines:
- Entering the parent context (span + analysis context)
- Setting the current file in context
- Creating a debug span for the file
- Incrementing the processed count
Use this for the common pattern of processing files in parallel.
§Arguments
path- The file being processedparent_ctx- The context captured from the parent threadf- The closure to execute
§Example
ⓘ
let ctx = ParallelContext::capture();
files.par_iter().map(|path| {
process_file_with_context(path, &ctx, || {
// If panic here, crash report shows:
// - Phase from parent context
// - File: /path/to/current/file.rs
// - Span: parent_span > process_file
analyze_file(path)
})
}).collect()