Rust · Course navigation

Rust Basics

Bind values and print them.

On this page

The concept

let creates a binding. println! is a macro that formats and writes a line. Bindings are immutable unless declared mut.

Code example

Rust
fn main() {
    let name = "Ada";
    println!("Hello, {}", name);
}
Output
Hello, Ada

Follow the code

Open the walkthrough to inspect the example one step at a time.

Show guided walkthrough
Guided walkthroughReady
1fn main() {
2 let name = "Ada";
3 println!("Hello, {}", name);
4}

Follow the example

Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.

View the complete dry-run table
Prepared trace of the published program. Some rows group repeated iterations.
Step / lineWhat happensState after stepOutput so far
Bind an immutable string slice to name.name = "Ada"
—
The macro substitutes name into the placeholder.name = "Ada"
Hello, Ada

Behind the scenes

How Rust processes this code

Rust checks types and ownership at compile time, then builds a native executable.