Trait Try

Source
pub trait Try {
    type Ok;
    type Error;

    // Required methods
    fn into_result(self) -> Result<Self::Ok, Self::Error>;
    fn from_error(v: Self::Error) -> Self;
    fn from_ok(v: Self::Ok) -> Self;
}
Expand description

A stable version of core::ops::Try.

Required Associated Types§

Source

type Ok

The type of this value when viewed as successful.

Source

type Error

The type of this value when viewed as failed.

Required Methods§

Source

fn into_result(self) -> Result<Self::Ok, Self::Error>

A return of Ok(t) means that the execution should continue normally, and the result of ? is the value t. A return of Err(e) means that execution should branch to the innermost enclosing catch, or return from the function.

Source

fn from_error(v: Self::Error) -> Self

Wrap an error value to construct the composite result. For example, Result::Err(x) and Result::from_error(x) are equivalent.

Source

fn from_ok(v: Self::Ok) -> Self

Wrap an OK value to construct the composite result. For example, Result::Ok(x) and Result::from_ok(x) are equivalent.

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.

Implementations on Foreign Types§

Source§

impl<T> Try for Option<T>

Source§

type Ok = T

Source§

type Error = NoneError

Source§

fn into_result(self) -> Result<<Self as Try>::Ok, <Self as Try>::Error>

Source§

fn from_error(_v: <Self as Try>::Error) -> Self

Source§

fn from_ok(v: <Self as Try>::Ok) -> Self

Source§

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

Source§

type Ok = T

Source§

type Error = E

Source§

fn into_result(self) -> Result<<Self as Try>::Ok, <Self as Try>::Error>

Source§

fn from_error(v: <Self as Try>::Error) -> Self

Source§

fn from_ok(v: <Self as Try>::Ok) -> Self

Source§

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

Source§

type Ok = Poll<Option<T>>

Source§

type Error = E

Source§

fn into_result(self) -> Result<<Self as Try>::Ok, <Self as Try>::Error>

Source§

fn from_error(v: <Self as Try>::Error) -> Self

Source§

fn from_ok(v: <Self as Try>::Ok) -> Self

Source§

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

Source§

type Ok = Poll<T>

Source§

type Error = E

Source§

fn into_result(self) -> Result<Self::Ok, Self::Error>

Source§

fn from_error(e: Self::Error) -> Self

Source§

fn from_ok(x: Self::Ok) -> Self

Implementors§