Start with a complete program. Rust code uses keywords and punctuation to say what should run.
fn main() {
println!("Hello, Rust!");
}fndefines a function: a named piece of code.mainis where this small executable starts. Its empty()means it takes no arguments.{and}surround the function body.println!is a macro that prints text followed by a new line. The!is part of the macro call syntax.- Double quotes surround text. The semicolon ends the printing statement.
Save this as main.rs. In a terminal on macOS/Linux, run:
rustc main.rs
./main
In Windows PowerShell, run:
rustc main.rs
.\main.exe
The program prints one line. Choose Explore beside the Rust example to inspect any piece.