[][src]Macro matux::unwrap

macro_rules! unwrap {
    ($src:expr, $pat:pat => $proj:expr) => { ... };
}

Asserts that an expression follows a pattern.

Example

enum A {
    B(&'static str),
    C(u32),
}

let c = A::C(3);
let inner = matux::unwrap!(c, A::C(x) => x);
assert_eq!(inner, 3u32);
enum A {
    B(&'static str),
    C(u32),
}

let c = A::C(3);
matux::unwrap!(c, A::B(x) => x); // Error: "A::B(x) does not match c"