The function-like macros are a type of procedural macros that look like
function calls.
They can, however, accept an unknown number of arguments.
Like the declarative macros they end with an exclamation mark (!).
A list of the main function-like macros is provided in
Table 1.
Table 1:Most used function-like macros
Macro | Description | Example |
|---|---|---|
| Create a formatted |
|
| Print formatted text on standard output stream. |
|
| Same as | |
| Same as |
|
| Same as | |
| Issue an unrecoverable error. |
|
| Mark unfinished code section. Panic if reached. |
|
| Mark non-implemented code section. Panic if reached. |
|
| Mark unreachable code. Panic if reached. |
|
Example with the println! macro:
println!("Good morning.");Good morning.
The same macro can accept additional arguments:
let name = "John";
println!("Good morning, {}.", name);Good morning, John.