pub trait DiagnosticResultExt<'d, T> {
    // Required methods
    fn ok_output(self) -> Option<T>;
    fn diagnostics(&self) -> &[BoxedDiagnostic<'d>];
    fn map_output<U, F>(self, f: F) -> DiagnosticResult<'d, U>
       where F: FnOnce(T) -> U;
    fn and_then_diagnose<U, F>(self, f: F) -> DiagnosticResult<'d, U>
       where F: FnOnce(T) -> DiagnosticResult<'d, U>;
}
Expand description

Extension methods for DiagnosticResults.

Required Methods§

source

fn ok_output(self) -> Option<T>

Converts from DiagnosticResult<'_, T> into Option<T>.

This function is similar to Result::ok, but gets only the non-diagnostic output T from the Ok variant in DiagnosticResult, discarding diagnostics.

source

fn diagnostics(&self) -> &[BoxedDiagnostic<'d>]

Gets the Diagnostics associated with the DiagnosticResult.

Both the success and failure case may include diagnostics.

source

fn map_output<U, F>(self, f: F) -> DiagnosticResult<'d, U>where F: FnOnce(T) -> U,

Maps DiagnosticResult<'d, T> into DiagnosticResult<'d, U> by applying a function over the non-diagnostic output of the Ok variant.

This function is similar to Result::map, but maps only the non-diagnostic output T from the Ok variant in DiagnosticResult, ignoring diagnostics.

source

fn and_then_diagnose<U, F>(self, f: F) -> DiagnosticResult<'d, U>where F: FnOnce(T) -> DiagnosticResult<'d, U>,

Calls the given function if the DiagnosticResult is Ok and otherwise returns the Err variant of the DiagnosticResult.

This function is similar to Result::and_then, but additionally forwards and collects diagnostics.

Implementors§

source§

impl<'d, T> DiagnosticResultExt<'d, T> for DiagnosticResult<'d, T>