Expand description
§Typed macros
A traditional macro can’t natively have arguments with type, they can only
accept a handful of meta types (expr
, ident
, vis
…), with this crate
you can explicitely say the type of the argument you want the macro to take.
§Example
use typed_macros::macrox;
macrox! {
/// You can even use attributes!
#[macro_export]
macro foo(bar: String) {
// Do something with bar...
}
}
fn main() {
foo!(String::from("Some string")) // <- This won't throw an error.
// foo!(9u32) // <- This will throw an error.
}
The main macro is macrox
, it takes an input like macro name(arg1: type1, arg2: type2) { /* Code */ }
, both the macrox
Macros§
- macrox
- Macrox