maidsafe_utilities::unwrap_result!
[−]
[src]
macro_rules! unwrap_result { ($result:expr) => { ... }; }
A replacement for calling unwrap()
on a Result
.
This macro is intended to be used in all cases where we unwrap
a Result
to deliberately
panic in case of error, e.g. in test-cases. Such unwrap
s don't give a precise point of
failure in our code and instead indicate some line number in the Rust core library. This macro
provides a precise point of failure and decorates the failure for easy viewing.
Examples
let some_result: Result<String, std::io::Error> = Ok("Hello".to_string()); let string_length = unwrap_result!(some_result).len(); assert_eq!(string_length, 5);