Concept Flow - Writing first Rust program
Start program
Call main function
Execute println! macro
Print message to screen
End program
The program starts by calling the main function, which runs the println! macro to print a message, then ends.
fn main() {
println!("Hello, world!");
}| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Start program | Program begins | Ready to run main() |
| 2 | Call main function | Enter main() | Inside main() |
| 3 | Execute println! macro | Print string | Displays: Hello, world! |
| 4 | End main function | main() finishes | Program ends |
| Variable | Start | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|
| No variables | N/A | N/A | N/A | N/A |
fn main() { ... } defines the program start.
Use println!("text") to print messages.
Program runs main(), executes println!, then ends.
println! is a macro for printing.
No variables needed for this simple program.