Skip to main content

Your first Rust program

Rust is compiled ahead of time: nothing runs until rustc has turned your source into native machine code. That is why the errors show up before the output, not halfway through it.

Work through the steps below. Each one has a checkpoint that ticks itself the moment your code and the real compiler output satisfy it — nothing to submit, nothing to click.

Step 1 of 3

Give the program an entry point

Write a `fn main()` function and print any greeting you like with `println!`.

Rust has no top-level script body. The operating system needs one named starting point, and `main` is it.

Checkpoints

  • The code declares `fn main()` — not yet passed
  • It calls the `println!` macro — not yet passed
  • The program compiles and runs without errors — not yet passed
  • Something was actually printed — not yet passed