Contains the macros try_or!
and try_or_else!
, which are to try!
what unwrap_or
and unwrap_or_else
are to unwrap()
.
Add to your Cargo.toml:
toml
[dependencies]
try_or = "0.1"
Use the macros like this:
```rust
extern crate try_or;
fn main() {
// test tryor!
asserteq!({ || tryor!("5".parse::
// test try_or_else!
assert_eq!({ || try_or_else!("1".parse::<u32>(), |_| 5) } (), 1);
assert_eq!({ || try_or_else!("a".parse::<u32>(), |_| 5) } (), 5);
} ```