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.
```rust 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
You can run cargo test
in the root directory, but you'll only see an error (an intended error) because the macro this_should_warn
was asking for a u32
type, and the test tried to use it with a String
.