Macro trackable::track_try_unwrap
source · macro_rules! track_try_unwrap { ($expr:expr) => { ... }; ($expr:expr, $($format_arg:tt)*) => { ... }; }
Expand description
More human readable variant of the standard Result::unwrap
method.
Examples
#[macro_use]
extern crate trackable;
use trackable::error::{Failed, Failure, ErrorKindExt};
fn main() {
let result: Result<(), Failure> = Err(Failed.error().into());
// Following two expressions are conceptually equivalent.
result.clone().unwrap();
track_try_unwrap!(result.clone());
// `track_try_unwrap!()` can take additional arguments compatible to `format!()`.
result.clone().expect(&format!("Additional information: {}", "foo"));
track_try_unwrap!(result.clone(), "Additional information: {}", "foo");
}