respector 0.1.2

An extension to add inspect method to Option and Result types.
Documentation
  • Coverage
  • 57.14%
    4 out of 7 items documented4 out of 6 items with examples
  • Size
  • Source code size: 7.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 664.25 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • rami3l/respector
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rami3l

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)`.