Attribute Macro methods_enum::gen
source · [−]#[gen]Expand description
Based on the signatures of the methods of the impl block, the are formed:
enum with options from the tuples of arguments, and
{} bodies of these methods with a call to the argument handler method from this enum.
This allows the handler method to control the behavior of the methods depending on the context.
There are two syntax options:
1- For the case where methods returning a value have the same return type:
#[methods_enum::gen(EnumName: handler_name)]
where:
- EnumName: the name of the automatically generated enum.
- handler_name: handler method name
2- In case of more than one meaningful return type:
#[methods_enum::gen(EnumName: handler_name=OutName)]
where:
- OutName: the name of the automatically generated enum with options from single tuples of return types.
In this case, you can also specify default return value expressions.
See the crate documentation for details.