macro_rules! define_input {
( $type_name:ident $( { $($fields:tt)* } )? ,
$get_function_name:ident, $output_type:ty) => { ... };
( $type_name:ident $( { $($fields:tt)* } )? ,
$get_function_name:ident, cloned $output_type:ty) => { ... };
( $type_name:ident $( { $( $field_name:ident : $field_type:ty),* } )? ,
$get_function_name:ident, $output_type:ty ; $clone_function:expr ; $($output_ref:tt)* ) => { ... };
}Expand description
Helper macro to define an input type. This will define the type for you along with
an OutputTypeForInput impl and a function wrapper for db.get(ComputationType::new()).
Note that inputs must be set via db.update_input(MyInputType, value) before they are used.
Example usage:
// Defines the `SourceFile` type, a `get_source` function to get the current
// source file, and the output type String.
define_input!(SourceFile, get_source, String);
// Inputs can have arguments on their type as well.
// The output type can also be prefixed with `cloned` if the getter should
// return it cloned instead of a reference
define_input!(SourceFile2 { file_id: u32 }, get_source2, cloned String);