respector

Crates.iorespector
lib.rsrespector
version0.1.2
sourcesrc
created_at2021-03-25 16:11:11.123084
updated_at2021-04-13 11:15:36.354637
descriptionAn extension to add inspect method to Option and Result types.
homepagehttps://github.com/rami3l/respector
repositoryhttps://github.com/rami3l/respector
max_upload_size
id373444
size7,412
rami3l (rami3l)

documentation

README

respector

Downloads License crates.io docs.rs

An extension to add inspect method to Option and Result types.

This allows doing something with the value contained in a Some, an Ok (with inspect) or an Err (with inspect_err) while passing the value on, which can be useful for introducing side effects in debugging, logging, etc.

Usage

use respector::prelude::*;

let some = Some(10);
assert_eq!(some.inspect(|x| println!("Some({})", x)), some); // Prints `Some(10)`.

let ok = Ok::<_, ()>(10);
assert_eq!(ok.inspect(|x| println!("Ok({})", x)), ok); // Prints `Ok(10)`.

let err = Err::<(), _>(10);
assert_eq!(Err(10).inspect_err(|x| println!("Err({})", x)), err); // Prints `Err(10)`.
Commit count: 9

cargo fmt