pub trait Try {
type Output;
type Residual;
// Required methods
fn from_output(output: Self::Output) -> Self;
fn from_residual(residual: Self::Residual) -> Self;
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
// Provided methods
fn unwrap(self) -> Self::Output
where Self: Sized { ... }
fn expect(self, message: impl Display) -> Self::Output
where Self: Sized { ... }
}
Expand description
Divergent (fallible) types.
This trait abstracts the branching of types that represent independent outputs and non-outputs (errors). Such types must be constructible from these variants and queried for a corresponding control flow.
Required Associated Types§
Required Methods§
fn from_output(output: Self::Output) -> Self
fn from_residual(residual: Self::Residual) -> Self
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
Provided Methods§
fn unwrap(self) -> Self::Outputwhere
Self: Sized,
fn expect(self, message: impl Display) -> Self::Outputwhere
Self: Sized,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.