Syntax
Rust Main Function Syntax
In Rust, main function: the entry point of a Rust program — fn main() {
}
Quick Answer
- Syntax
fn main() {
}
RustSyntax
Main Function
Code example
fn main() {
}
The entry point of a Rust program.
How to main function in Rust
- Open your Rust file or editor.
- Copy the example, then replace its sample names and values for your code.
Rust Main Function Syntax
Use fn main() {
}.
Related Syntax References
Frequently asked questions
What is the Rust syntax for main function?
Use this pattern: fn main() {
}
Can I copy this Rust code example?
Yes. Use Copy code and adapt the example to your program.
Is this Rust syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify