Trait respector::prelude::ResultInspector[][src]

pub trait ResultInspector<T, E> {
    fn inspect<F: FnMut(&T)>(self, f: F) -> Result<T, E>;
fn inspect_err<F: FnMut(&E)>(self, f: F) -> Result<T, E>; }

Required methods

fn inspect<F: FnMut(&T)>(self, f: F) -> Result<T, E>[src]

Does something with the contained Ok value element of a Result, passing the value on.

Examples

use respector::prelude::*;

assert_eq!(
    Ok::<_, ()>(10).inspect(|x| println!("Ok({})", x)),
    Ok(10)
); // Prints `Ok(10)`.
assert_eq!(
    Err::<(), _>(10).inspect(|x| println!("Ok({:?})", x)),
    Err(10)
); // Prints nothing.

fn inspect_err<F: FnMut(&E)>(self, f: F) -> Result<T, E>[src]

Does something with the contained Err value element of a Result, passing the value on.

Examples

use respector::prelude::*;

assert_eq!(
    Err::<(), _>(10).inspect_err(|x| println!("Err({})", x)),
    Err(10)
); // Prints `Err(10)`.
assert_eq!(
    Ok::<_, ()>(10).inspect_err(|x| println!("Err({:?})", x)),
    Ok(10)
); // Prints nothing.
Loading content...

Implementations on Foreign Types

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

Loading content...

Implementors

Loading content...