Skip to main content

ResConv

Trait ResConv 

Source
pub trait ResConv<T, E> {
    // Required methods
    fn into_option(self) -> Option<T>;
    fn into_result(self) -> Result<T, E>;
}
Expand description

Conversions between Result and Option with optional value transformation.

Required Methods§

Source

fn into_option(self) -> Option<T>

Converts into Option<T>, dropping any error information.

Source

fn into_result(self) -> Result<T, E>

Converts into Result<T, E>.

§Errors

Returns Err(E) when the source value represents an absent or failed state.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<Input, Output, Err: Default> ResConv<Output, Err> for Option<Input>
where Input: Into<Output>,

Source§

fn into_result(self) -> Result<Output, Err>

  • Transforms Some(T) into Ok(T).
  • Transforms None into Err(Err::Default())
§Errors
  • Returns Err(Err::Default()) if self is None.
Source§

fn into_option(self) -> Option<Output>

Source§

impl<Input, Output, Err> ResConv<Output, Err> for Result<Input, Err>
where Input: Into<Output>,

Source§

fn into_option(self) -> Option<Output>

Source§

fn into_result(self) -> Result<Output, Err>

Implementors§