1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
macro_rules! define_event_header {
    ($event_ident: ident: $func_ident: ty) => {
        pub struct $event_ident {
            funcs: Vec<$func_ident>,
        }

        impl $event_ident {
            pub fn new(funcs: Vec<Func>) -> Result<Self> {
                let mut casted_funcs = Vec::with_capacity(funcs.len());

                for func in funcs {
                    let casted_func = try!(DllResult::<$func_ident>::from(func));
                    casted_funcs.push(casted_func);
                }

                let result =
                    $event_ident {
                        funcs: casted_funcs,
                    };
                Ok(result)
            }
        }
    }
}