Exclamation mark in Rust !

exclamation mark ! macro not

There are a number of places where we can see exclamation marks ! in Rust.

Never type

As the designated return type of a function:

fn foo() -> ! {

Diverging Functions - functions that never return


At the end of "function" names:

println!("Hello World");

Functions that end with an exclamation mark !

Boolean not

In boolean expressions:

if ! var.is_empty() {

Boolean not !

Not equal !=

Comparing values for lack of equality:

if answer != 42 {

Related Pages

Default arguments for functions in Rust using macros


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