Skip to content
the daily practice28 real-world stories

A little Rust.
Less rusty.

Small stories from real code. Work through a few, understand the why, and come back just before you forget.

explore the map ↗
01 Syntaxa taste of the practice

Start with a complete program. Rust code uses keywords and punctuation to say what should run.

rust
fn main() {
    println!("Hello, Rust!");
}
  • fn defines a function: a named piece of code.
  • main is 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.

What does this program print?

Choose one answer.
Your next session adapts to what you know.
how am I doing? ↗