Skip to main content

define_function

Macro define_function 

Source
macro_rules! define_function {
    (
        $registry:expr
        =>
        $(mod $module_name:ident)?
        $(type ($type:ty))?
        fn
        $name:ident
        ($( $input_name:ident : $input_type:ty),*)
        ->
        ($( $output_name:ident : $output_type:ty),*)
        $code:block
    ) => { ... };
}
Expand description

Builds a whole Function from a signature and a Rust body.

The body is a block whose value is a tuple of the outputs. Arguments arrive as ordinary local variables.

define_function! {
    registry => mod lib fn add(a: i32, b: i32) -> (result: i32) {
        (a + b,)
    }
}