This PR adds Report::with_labels, a chainable equivalent of Report::add_labels. This brings a minor DX improvement for the common use case where a report includes an iterable of errors, such as when parsing input with chumsky.
Before
if let Err(errors) = parser().parse(&input) {
let mut report =
Report::build(ReportKind::Error, &filename, 0).with_message("Error parsing file");
report.add_labels(errors.iter().map(|error| {
Label::new((&filename, error.span())).with_message(format!("{}", error))
}));
report
.finish()
.eprint((&filename, Source::from(&input)))
.unwrap();
}
This PR adds
Report::with_labels
, a chainable equivalent ofReport::add_labels
. This brings a minor DX improvement for the common use case where a report includes an iterable of errors, such as when parsing input with chumsky.Before
After