1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
macro_rules! define_func { ( ($input: ty, $output: ty) { $func_none_ident: ident, $func_input_ident: ident, $func_output_ident: ident, $func_input_output_ident: ident } ) => { define_func_header!($func_none_ident: fn() -> FuncResult<()>); define_func_header!($func_input_ident: fn($input) -> FuncResult<()>); define_func_header!($func_output_ident: fn() -> FuncResult<$output>); define_func_header!($func_input_output_ident: fn($input) -> FuncResult<$output>); impl $func_none_ident { pub unsafe fn call(&self) -> Result<()> { let func = self.func.get(); func().map_err(|err| Error::from(err)) } } impl $func_input_ident { pub unsafe fn call(&self, input: $input) -> Result<()> { let func = self.func.get(); func(input).map_err(|err| Error::from(err)) } } impl $func_output_ident { pub unsafe fn call(&self) -> Result<$output> { let func = self.func.get(); func().map_err(|err| Error::from(err)) } } impl $func_input_output_ident { pub unsafe fn call(&self, input: $input) -> Result<$output> { let func = self.func.get(); func(input).map_err(|err| Error::from(err)) } } } }