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: DiagnosticSetImplementations§
Source§impl<T, E> Outcome<T, E>
impl<T, E> Outcome<T, E>
Sourcepub fn is_ok(&self) -> bool
pub fn is_ok(&self) -> bool
Returns true if this outcome represents success according to the default failure policy
Sourcepub fn is_ok_with_policy<P>(&self, policy: &P) -> boolwhere
P: ?Sized + FailurePolicy,
pub fn is_ok_with_policy<P>(&self, policy: &P) -> boolwhere
P: ?Sized + FailurePolicy,
Returns true if this outcome represents success according to policy
Sourcepub fn is_err(&self) -> bool
pub fn is_err(&self) -> bool
Returns true if this outcome represents failure according to the default failure policy
Sourcepub fn is_err_with_policy<P>(&self, policy: &P) -> boolwhere
P: ?Sized + FailurePolicy,
pub fn is_err_with_policy<P>(&self, policy: &P) -> boolwhere
P: ?Sized + FailurePolicy,
Returns true if this outcome represents failure according to policy
Sourcepub fn map<U>(self, mapper: impl FnOnce(T) -> U) -> Outcome<U, E>
pub fn map<U>(self, mapper: impl FnOnce(T) -> U) -> Outcome<U, E>
Transform the value associated with this outcome, preserving the diagnostics
Source§impl<T, E> Outcome<T, E>
impl<T, E> Outcome<T, E>
Sourcepub fn expect(self, message: &str) -> T
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.
Sourcepub fn expect_err(self, message: &str) -> DiagnosticSet
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
Sourcepub fn into_result(self) -> Result<T, Report>
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
Sourcepub fn into_result_with_policy<P>(self, policy: &P) -> Result<T, Report>where
P: ?Sized + FailurePolicy,
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
Sourcepub fn into_exit(self) -> ExitWithOutcome<T>
pub fn into_exit(self) -> ExitWithOutcome<T>
Converts this outcome into the std application’s rich termination path.
Source§impl<T> Outcome<T, ()>
impl<T> Outcome<T, ()>
pub fn from_report(report: Report) -> Self
Sourcepub fn expect(self, message: &str) -> T
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.
Sourcepub fn expect_err(self, message: &str) -> DiagnosticSet
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
Sourcepub fn into_result(self) -> Result<T, Report>
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
Sourcepub fn into_result_with_policy<P>(self, policy: &P) -> Result<T, Report>where
P: ?Sized + FailurePolicy,
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
Sourcepub fn into_exit(self) -> ExitWithOutcome<T>
pub fn into_exit(self) -> ExitWithOutcome<T>
Converts this outcome into the std application’s rich termination path.