Skip to main content

Outcome

Struct Outcome 

Source
pub struct Outcome<T, E = ()> {
    pub result: Result<T, E>,
    pub diagnostics: DiagnosticSet,
}
Expand description

An Outcome represents the output of a computation and the set of diagnostics that were produced during that computation. Diagnostics may or may not indicate failure, so this type does not treat an outcome as either/or - a successful outcome may still produce diagnostics, which is the primary distinction between this type and core::result::Result<T, E>.

Fields§

§result: Result<T, E>§diagnostics: DiagnosticSet

Implementations§

Source§

impl<T, E> Outcome<T, E>

Source

pub fn is_ok(&self) -> bool

Returns true if this outcome represents success according to the default failure policy

Source

pub fn is_ok_with_policy<P>(&self, policy: &P) -> bool
where P: ?Sized + FailurePolicy,

Returns true if this outcome represents success according to policy

Source

pub fn is_err(&self) -> bool

Returns true if this outcome represents failure according to the default failure policy

Source

pub fn is_err_with_policy<P>(&self, policy: &P) -> bool
where P: ?Sized + FailurePolicy,

Returns true if this outcome represents failure according to policy

Source

pub fn map<U>(self, mapper: impl FnOnce(T) -> U) -> Outcome<U, E>

Transform the value associated with this outcome, preserving the diagnostics

Source

pub fn map_err<U>(self, mapper: impl FnOnce(E) -> U) -> Outcome<T, U>

Transform the error value associated with this outcome, preserving the diagnostics

Source

pub fn and_then<U>( self, mapper: impl FnOnce(T, &mut DiagnosticCollector) -> Result<U, E>, ) -> Outcome<U, E>

Transform the value with a fallible associated with this outcome, preserving the diagnostics

Source§

impl<T, E> Outcome<T, E>
where Report: From<E>,

Source

pub fn unwrap(self) -> T

Unwrap a successful outcome/value of type T, or panic.

Source

pub fn expect(self, message: &str) -> T

Expect this outcome to have successfully produced a value of T, or panic with message

Returns the T that was produced, and discards the diagnostics.

Source

pub fn expect_err(self, message: &str) -> DiagnosticSet

Expect this outcome to have failed to produce a value of T, or panic with message

Returns the diagnostics associated with this outcome

Source

pub fn into_result(self) -> Result<T, Report>

Convert this outcome into a Result<T, Report> using the default failure policy

If the inner Result of this outcome is an error, it will be converted to a Report as the primary diagnostic

Source

pub fn into_result_with_policy<P>(self, policy: &P) -> Result<T, Report>
where P: ?Sized + FailurePolicy,

Convert this outcome into a Result<T, Report> using the provided failure policy

Source

pub fn into_exit(self) -> ExitWithOutcome<T>

Converts this outcome into the std application’s rich termination path.

Source§

impl<T> Outcome<T, ()>

Source

pub fn from_report(report: Report) -> Self

Source

pub fn unwrap(self) -> T

Unwrap a successful outcome/value of type T, or panic.

Source

pub fn expect(self, message: &str) -> T

Expect this outcome to have successfully produced a value of T, or panic with message

Returns the T that was produced, and discards the diagnostics.

Source

pub fn expect_err(self, message: &str) -> DiagnosticSet

Expect this outcome to have failed to produce a value of T, or panic with message

Returns the diagnostics associated with this outcome

Source

pub fn into_result(self) -> Result<T, Report>

Convert this outcome into a Result<T, Report> using the default failure policy

If the inner Result of this outcome is an error, it will be converted to a Report as the primary diagnostic

Source

pub fn into_result_with_policy<P>(self, policy: &P) -> Result<T, Report>
where P: ?Sized + FailurePolicy,

Convert this outcome into a Result<T, Report> using the provided failure policy

Source

pub fn into_exit(self) -> ExitWithOutcome<T>

Converts this outcome into the std application’s rich termination path.

Trait Implementations§

Source§

impl<T: Debug, E: Debug> Debug for Outcome<T, E>

Source§

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

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

impl<T> From<Outcome<T>> for ExitWithOutcome<T>

Source§

fn from(outcome: Outcome<T>) -> Self

Converts to this type from the input type.
Source§

impl<T, E> From<Result<T, E>> for Outcome<T, E>

Source§

fn from(result: Result<T, E>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for Outcome<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T, E = ()> !RefUnwindSafe for Outcome<T, E>

§

impl<T, E = ()> !UnwindSafe for Outcome<T, E>

§

impl<T, E> Forget for Outcome<T, E>

§

impl<T, E> Freeze for Outcome<T, E>
where Result<T, E>: Freeze,

§

impl<T, E> Move for Outcome<T, E>

§

impl<T, E> Send for Outcome<T, E>
where Result<T, E>: Send,

§

impl<T, E> Sync for Outcome<T, E>
where Result<T, E>: Sync,

§

impl<T, E> Unpin for Outcome<T, E>
where Result<T, E>: Unpin,

§

impl<T, E> UnsafeUnpin for Outcome<T, E>
where Result<T, E>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.