| Crates.io | respector |
| lib.rs | respector |
| version | 0.1.2 |
| created_at | 2021-03-25 16:11:11.123084+00 |
| updated_at | 2021-04-13 11:15:36.354637+00 |
| description | An extension to add inspect method to Option and Result types. |
| homepage | https://github.com/rami3l/respector |
| repository | https://github.com/rami3l/respector |
| max_upload_size | |
| id | 373444 |
| size | 7,412 |
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.
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)`.