Trait std::ops::Try [−][src]
pub trait Try {
type Ok;
type Error;
pub fn into_result(self) -> Result<Self::Ok, Self::Error>;
pub fn from_error(v: Self::Error) -> Self;
pub fn from_ok(v: Self::Ok) -> Self;
}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]
The type of this value when viewed as successful.
type Error[src]
The type of this value when viewed as failed.
Required methods
pub fn into_result(self) -> Result<Self::Ok, Self::Error>[src]
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.
pub fn from_error(v: Self::Error) -> Self[src]
Wrap an error value to construct the composite result. For example,
Result::Err(x) and Result::from_error(x) are equivalent.
pub fn from_ok(v: Self::Ok) -> Self[src]
Wrap an OK value to construct the composite result. For example,
Result::Ok(x) and Result::from_ok(x) are equivalent.
Implementors
impl<B, C> Try for ControlFlow<B, C>[src]
impl<B, C> Try for ControlFlow<B, C>[src]type Ok = C
type Error = B
pub fn into_result(
self
) -> Result<<ControlFlow<B, C> as Try>::Ok, <ControlFlow<B, C> as Try>::Error>[src]
self
) -> Result<<ControlFlow<B, C> as Try>::Ok, <ControlFlow<B, C> as Try>::Error>
pub fn from_error(v: <ControlFlow<B, C> as Try>::Error) -> ControlFlow<B, C>[src]
pub fn from_ok(v: <ControlFlow<B, C> as Try>::Ok) -> ControlFlow<B, C>[src]
impl<T, E> Try for Poll<Option<Result<T, E>>>1.36.0[src]
impl<T, E> Try for Poll<Option<Result<T, E>>>1.36.0[src]type Ok = Poll<Option<T>>
type Error = E
pub fn into_result(
self
) -> Result<<Poll<Option<Result<T, E>>> as Try>::Ok, <Poll<Option<Result<T, E>>> as Try>::Error>[src]
self
) -> Result<<Poll<Option<Result<T, E>>> as Try>::Ok, <Poll<Option<Result<T, E>>> as Try>::Error>
pub fn from_error(
e: <Poll<Option<Result<T, E>>> as Try>::Error
) -> Poll<Option<Result<T, E>>>[src]
e: <Poll<Option<Result<T, E>>> as Try>::Error
) -> Poll<Option<Result<T, E>>>
pub fn from_ok(
x: <Poll<Option<Result<T, E>>> as Try>::Ok
) -> Poll<Option<Result<T, E>>>[src]
x: <Poll<Option<Result<T, E>>> as Try>::Ok
) -> Poll<Option<Result<T, E>>>
impl<T, E> Try for Poll<Result<T, E>>1.36.0[src]
impl<T, E> Try for Poll<Result<T, E>>1.36.0[src]type Ok = Poll<T>
type Error = E
pub fn into_result(
self
) -> Result<<Poll<Result<T, E>> as Try>::Ok, <Poll<Result<T, E>> as Try>::Error>[src]
self
) -> Result<<Poll<Result<T, E>> as Try>::Ok, <Poll<Result<T, E>> as Try>::Error>