Macros
Diplomat has support for generating bindings with macro_rules!, with quite a few caveats:
- Any
macro_rules
definitions that you wish Diplomat to evaluate must use the#[diplomat::macro_rules]
attribute. - Macros can only contain a single arm. The arm can contain any syntax as defined , with three exceptions:
- The
pat
andstmt
MacroFragSpecs are currently forbidden. - The
$(MacroMatch+) MacroRepSep? MacroRepOp
pattern is currently forbidden.
- The
- Macros can exist only in
#[diplomat::bridge] mod ... { ... }
blocks orimpl
blocks. - Macros exist solely in the file you've defined them in. They must also be defined first.
- Macros do not use interpolation matchers, nor do they allow recursive usage of other
#[diplomat::macro_rules]
macros.