Functions that end with an exclamation mark in Rust !

exclamation mark ! macro

As you read Rust code you will see many function calls that have an exclamation mark ! at the end.

Some of the most common ones are:

In reality, these are called macros. They are replaced by more Rust code at compile time.

There are a number of macros in the standard library and there are many crates sharing additional macros.

Macros can be useful to eliminate duplicate code that for some reason we cannot, or do not want to put in a function.

They can also include Rust code that would be executed during the compilation of the code.

Related Pages

Exclamation mark in Rust !

Author

Gabor Szabo (szabgab)

Gabor Szabo, the author of the Rust Maven web site maintains several Open source projects in Rust and while he still feels he has tons of new things to learn about Rust he already offers training courses in Rust and still teaches Python, Perl, git, GitHub, GitLab, CI, and testing.

Gabor Szabo