[][src]Macro dynerr::dynmatch

macro_rules! dynmatch {
    ($e:expr, $(type $ty:ty {$(arm $pat:pat => $result:expr),*, _ => $any:expr}),*, _ => $end:expr) => { ... };
}

performs a dynamic match operation on multiple error types
takes the DynError, match arms, and default arm
types must be specified beforehand with the "type" keyword

#Example

This example is not tested
...
let i = match example(9) { //returns dyn error
    Ok(i) => i,
    Err(e) => {
        dynmatch!(e,                                                    //the error to match
            type ExampleError1 {                                        //error type group
                arm ExampleError1::ThisError(2) => panic!("it was 2!"), //arm [pattern] => {code}
                _ => panic!("{}",e)                                     //_ => {code}
            },
            type ExampleError2 {                                        //another error type
                arm ExampleError2::ThatError(8) => panic!("it was 8!"), //more arms
                arm ExampleError2::ThatError(9) => 9,
                _ => panic!("{}",e)                                     //more wildcard matches
            }, 
            _ => panic!("{}",e)                                         //final wildcard if type not found
        )
    }
};
...