Ensure that all your macros are given arguments with the correct type using the typed_macros crate [1.0.0 🎉]
You can use the typed_macros crate to check in compile-time that your macros are given arguments with the correct types (+ Easier macro declarations!)
Example
use typed_macros::macrox; // Import main macro
macrox! {
#[macro_export] // It can even take attributes!
macro example_macro(arg: String) {
// Do something with arg, for example printing it.
println!("{}", arg);
}
}
fn main() {
example_macro!(String::from("hi!")); // <- This will not throw an error.
example_macro!(9u32) // <- This will throw an error, the macro requested a String type.
}
Both declaring the macro and using it is very simple, without slowing run-time performance.
If you're interested in using this crate for improving your development experience, you can go check the crates.io page, the documentation or the repository. (There's another example with syntax highlighting in the repo.)