[][src]Trait sp_std::ops::Try

#[lang = "try"]pub trait Try {
    type Ok;
    type Error;
#[lang = "into_result"]    pub fn into_result(self) -> Result<Self::Ok, Self::Error>;
#[lang = "from_error"] pub fn from_error(v: Self::Error) -> Self;
#[lang = "from_ok"] pub fn from_ok(v: Self::Ok) -> Self; }
🔬 This is a nightly-only experimental API. (try_trait)

A trait for customizing the behavior of the ? operator.

A type implementing Try is one that has a canonical way to view it in terms of a success/failure dichotomy. This trait allows both extracting those success or failure values from an existing instance and creating a new instance from a success or failure value.

Associated Types

type Ok[src]

🔬 This is a nightly-only experimental API. (try_trait)

The type of this value when viewed as successful.

type Error[src]

🔬 This is a nightly-only experimental API. (try_trait)

The type of this value when viewed as failed.

Loading content...

Required methods

#[lang = "into_result"]pub fn into_result(self) -> Result<Self::Ok, Self::Error>[src]

🔬 This is a nightly-only experimental API. (try_trait)

Applies the "?" operator. 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.

If an Err(e) result is returned, the value e will be "wrapped" in the return type of the enclosing scope (which must itself implement Try). Specifically, the value X::from_error(From::from(e)) is returned, where X is the return type of the enclosing function.

#[lang = "from_error"]pub fn from_error(v: Self::Error) -> Self[src]

🔬 This is a nightly-only experimental API. (try_trait)

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

#[lang = "from_ok"]pub fn from_ok(v: Self::Ok) -> Self[src]

🔬 This is a nightly-only experimental API. (try_trait)

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

Loading content...

Implementations on Foreign Types

impl<T, E> Try for Poll<Result<T, E>>[src]

type Ok = Poll<T>

🔬 This is a nightly-only experimental API. (try_trait)

type Error = E

🔬 This is a nightly-only experimental API. (try_trait)

impl<T> Try for Option<T>[src]

type Ok = T

🔬 This is a nightly-only experimental API. (try_trait)

type Error = NoneError

🔬 This is a nightly-only experimental API. (try_trait)

impl<T, E> Try for Poll<Option<Result<T, E>>>[src]

type Ok = Poll<Option<T>>

🔬 This is a nightly-only experimental API. (try_trait)

type Error = E

🔬 This is a nightly-only experimental API. (try_trait)
Loading content...

Implementors

impl<B, C> Try for ControlFlow<B, C>[src]

type Ok = C

🔬 This is a nightly-only experimental API. (try_trait)

type Error = B

🔬 This is a nightly-only experimental API. (try_trait)

impl<T, E> Try for Result<T, E>[src]

type Ok = T

🔬 This is a nightly-only experimental API. (try_trait)

type Error = E

🔬 This is a nightly-only experimental API. (try_trait)
Loading content...