maidsafe_utilities::unwrap_option! [] [src]

macro_rules! unwrap_option {
    ($option:expr, $user_string:expr) => { ... };
}

A replacement for calling unwrap() on an Option.

This macro is intended to be used in all cases where we unwrap an Option to deliberately panic in case of error, e.g. in test-cases. Such unwraps 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_option = Some("Hello".to_string());
let string_length = unwrap_option!(some_option, "This is a user-supplied text.").len();
assert_eq!(string_length, 5);