Skip to main content

Diagnostics

Struct Diagnostics 

Source
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

Source

pub fn new() -> Self

A collector with no problems recorded.

Source

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.

Source

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.

Source

pub fn is_empty(&self) -> bool

Whether no problems have been recorded.

Source

pub fn len(&self) -> usize

How many problems have been recorded.

Source

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.

Trait Implementations§

Source§

impl Debug for Diagnostics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Diagnostics

Source§

fn default() -> Diagnostics

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.