Quoted from the Rust blog:
One last thing to mention: Rust’s macros are significantly different from C macros, if you’ve used those
What is the difference between macros and function in Rust? How is it different from C?
Quoted from the Rust blog:
One last thing to mention: Rust’s macros are significantly different from C macros, if you’ve used those
What is the difference between macros and function in Rust? How is it different from C?
Keep on reading the documentation, specifically the chapter on macros!
Rust functions vs Rust macros
Macros are executed at compile time. They generally expand into new pieces of code that the compiler will then need to further process.
Rust macros vs C macros
The biggest difference to me is that Rust macros are hygenic. The book has an example that explains what hygiene prevents, and also says:
It uses this example:
Beyond that, Rust macros
In
macro
, you can take variable number of parameters.In
function
you have to define number and type of parameters.