Install Rust and run your first program

Learn Rust · Beginner · 8 min

How do you get from nothing to a running Rust program?

  1. 1Guess

    fn main() {
        println!("Hello");
        println!("{} + {} = {}", 2, 3, 2 + 3);
    }
    
    What does this program print?
  2. 2Read

    Install Rust

    Install Rust with rustup, the installer and version manager the Book recommends. On Linux and macOS you run one command from rustup.rs; on Windows you download the installer. Then open a new terminal and type rustc --version. If it prints a version number, Rust is installed. rustup update later moves you to a newer release.

  3. 3Read

    Make a project with Cargo

    Cargo is Rust's build system and package manager, and it comes with the installer. cargo new hello makes a folder with a Cargo.toml file, which names the package and lists its dependencies, and src/main.rs, which holds a "Hello, world!" program. cargo run builds and runs it. cargo build only builds. cargo check only checks that the code compiles, and is usually faster.

  4. 4Code

    A first program with println!

    1 / 2
    fn main() {
        let name = "Ferris";
        let age = 4;
        println!("Hello, {name}!");
        println!("{} is {} years old", name, age);
        println!("Next year: {}", age + 1);
    }
    

    Read the program. What will it print?

    Run it in the playground

  5. 5Read

    What the ! and the ; mean

    fn main() is the function Rust runs first. The ! in println! means you call a macro, not a normal function; write println without it and you call something else. A statement ends with ;, as the println! lines do. The Book formats code with four spaces, not a tab.

  6. 6Fix

    fn main() {
        println("Hello, Rust");
    }
    
    This program does not compile. What is the bug?
  7. 7Say it back

  8. 8Mission · 8 min

    Install Rust, check the version, make a project called hello and run the program Cargo generated. Then change the text in src/main.rs and run it again.

    rustc --version
    cargo new hello
    cd hello
    cargo run

Common questions

How do I install Rust?
Use rustup, the installer the Rust Book recommends. On Linux and macOS you run the command shown on rustup.rs in a terminal; on Windows you download and run the installer. When it finishes, open a new terminal and type rustc --version. A printed version number means Rust works. Later, rustup update installs the newest release.
What is Cargo in Rust?
Cargo is the build system and package manager that comes with Rust. It creates projects with cargo new, builds them, runs them and downloads the libraries your code depends on. Almost every Rust project uses it, so the commands you learn here, such as cargo run, work the same on Linux, macOS and Windows.
What is the difference between cargo run, cargo build and cargo check?
The cargo build command compiles your project and leaves an executable in the target/debug folder. The cargo run command builds the project if needed and then starts it. The cargo check command only checks that the code compiles and makes no executable, so it is usually faster while you are still writing the code.

Sources

Measured with rustc 1.100.1 (play.rust-lang.org, stable, edition 2024) on 2026-12-03

Published Dec 3, 2026 · Updated Dec 3, 2026

Never miss new offers and news

New tools, credits, and AI news are added regularly. Pick how you want to hear about them.

Telegram channel

Join @aifree_dev and get new free AI offers and news right in your Telegram feed.

Browser notifications

Turn on push notifications and get an alert on this device whenever something new is posted. No account needed.

Email newsletter

A weekly digest of new, changed and expiring free AI offers. Double opt-in, one-click unsubscribe. See the latest issue.

Unsubscribe anytime. Privacy

Frequently asked questions

What is aifree.dev?

aifree.dev helps everyone access AI through a curated directory of free AI tools, API credits, free tiers, and startup programs for coding, image, voice, video, and students - verified regularly.

How are offers presented?

Each offer includes its access details, free models when available, and expiration information when provided. Limited-time deals stay visible so they are easy to compare.

Do education and startup programs need verification?

Yes. Providers usually ask students to verify their status with a school email, student ID, or a program like the GitHub Student Pack, and ask startups to verify company details such as age, funding, or website. Check each offer’s claim page for the exact requirements.

What kinds of free AI offers are listed?

Free tiers and free trials from AI providers, free API credits, startup and student programs, and free tools for coding, image generation, voice, and video.

How can I suggest a tool or report a broken link?

Use the submit form: paste the offer page URL and a short note. A person checks every submission before anything is listed. Broken links and changed terms go through the same form.

Know a good one?

Tell us about an AI tool worth knowing. Found a broken link? We want to hear that too.

Submit an offer