Skip to main content

Try

Trait Try 

Source
pub trait Try: Sized {
    type Output;
    type Residual;

    // Required method
    fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
}
Expand description

Splitting an expression into a success value or an early-exit residual.

Required Associated Types§

Source

type Output

The type of the value produced when execution continues successfully.

Source

type Residual

The residual type passed to FromResidual::from_residual on early exit.

Required Methods§

Source

fn branch(self) -> ControlFlow<Self::Residual, Self::Output>

Splits self into either a continuation output or an early-exit residual.

Following RFC 3058, this returns ControlFlow which has identical ABI and zero-cost machine representation to Result while cleanly modeling early returns for non-error types like Option and Poll.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<B, C> Try for ControlFlow<B, C>

Source§

impl<T, E> Try for Poll<Result<T, E>>

Source§

impl<T, E> Try for Result<T, E>

Source§

impl<T> Try for Option<T>

Source§

impl<T> Try for Poll<Option<T>>

Implementors§