Attribute Macro methods_enum::gen
source · [−]#[gen]Expand description
Based on the method signatures of the impl block, it generates: enum with parameters
from argument tuples and generates {} bodies of these methods with calling the argument
handler method from this enum.
This allows the handler method to control the behavior of the methods depending on the context.
Macro call syntax
#[methods_enum::gen(EnumName , | : handler_name ( , | = OutName !? )? )]
where:
- EnumName: The name of the automatically generated enum.
- handler_name: Handler method name
- OutName (in case of more than one return type and/or to specify a default return values) : The name of an automatically generated enum with variants from the return types.
Replacing the delimiter , after EnumName with : or before OutName with =
will automatically add the #[derive(Debug)] attribute to the corresponding enum.
Setting ! after OutName enables checking the returned variant by its name, not by its type.
See the crate documentation for details.