pub struct Diagnostics { /* private fields */ }Expand description
A collector of independent semantic problems. One run reports every problem that it finds and does not stop at the first one.
Add a problem with Diagnostics::push. Add the result of a fallible check
with Diagnostics::check. End with Diagnostics::into_result.
Implementations§
Source§impl Diagnostics
impl Diagnostics
Sourcepub fn push(&mut self, problem: Error)
pub fn push(&mut self, problem: Error)
Record a problem and continue.
A problem that is itself a report opens and adds its problems one by one.
A check can collect on its own and give a report back, and a caller that
collects again would otherwise nest one report inside another. The reader
then gets a count that hides most of the list. Error::Validation
therefore holds leaf problems only, at one level.
Sourcepub fn check(&mut self, outcome: Result<()>)
pub fn check(&mut self, outcome: Result<()>)
Record the error from a failed check and continue.
Use this method for a check that returns a Result. That check keeps one
signature. A caller can then run it alone, or as part of this collection
pass.
Sourcepub fn into_result(self) -> Result<()>
pub fn into_result(self) -> Result<()>
Convert the collected problems into a result.
No problems give Ok(()). One problem returns as itself, so the caller
sees the error that a stop-at-first check gives. Two or more problems go
into an Error::Validation in discovery order.