Search⌘ K

Is main Special?

Explore how the main function serves as the entry point in Rust programs. Understand its required signature, why it cannot take parameters, and the restrictions on its return types to help you write correct Rust applications.

We'll cover the following...

Is the main function special? Yes and no. On the “no” side, main is defined just like any other function. The name it has isn’t off limits in any way, it can be used like any other name in Rust.

Rust 1.40.0
fn main() {
let main = "I can reuse the name main";
println!("main == {}", main);
}

However, main is ...