Expand description
Unpack multiple levels of Result<T, E>
and Option<T>
at once
use unwrap_all::unwrap_all;
let nested: Option<Result<Option<Result<usize, ()>>, ()>> = Some(Ok(Some(Ok(42))));
let unpacked = unwrap_all!(4, nested);
assert_eq!(42, unpacked);
This crate should work with no_std
too.
Macrosยง
- expect_
all - Running this function will give you a panic with the message
1 - must fail: 23
, where the1
tells you how many levels in the panic was caused. - unwrap_
all - Use it like this:
unwrap_all!(n_times, object)