Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

rami3l/respector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

respector

Warning: Deprecated in favor of rust-lang/rust#91345.


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

About

Add inspect method to Option and Result types.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages