macro_rules! cbk_new_callback_func {
($func_name:ident, $arg_name:ident, $body:block) => { ... };
}Expand description
This macro generates a function that take a reference to a Box<dyn Any>
as an argument and return nothing. The function body ($body) is the code
that will be execute when the callback is trigger.
§Usage
Use for defining functions required to create a Callback object,
§Parameters
func_name: An identifier (ident) representing the generated function name.arg_name: An identifier (ident) representing the function argument name.body: A block (block) containing the function implementation.
§Example
// A callback function that accept a u32 an print it out.
cbk_new_callback_func!(print_num, arg, {
println!("{}", cbk::cast_arg::<u32>(arg)?);
Ok(())
});