Rust Tutorial

Rust Tutorial“, almost always they mean:

A beginner-friendly guide to learn the Rust programming language (not the video game called Rust)

Rust (the programming language) is a modern, super-fast, super-safe systems programming language created by Mozilla (first versions around 2010, became very popular ~2015–2025).

People use Rust today to write:

  • Web servers (like parts of Discord, Dropbox)
  • Blockchain / crypto stuff
  • Game engines
  • Operating system kernels
  • CLI tools
  • Embedded devices
  • Anything where C/C++ was used before, but they want safety + speed

Okay, now let’s act like a real teacher and start from zero — slowly and with examples.

Step 1: What makes Rust special? (The 3 big promises)

Imagine I tell you three magical rules Rust enforces:

  1. Memory safety without garbage collector → No null pointer crashes, no use-after-free, no buffer overflow (like 70–80% of serious security bugs disappear)
  2. Fearless concurrency → You can use many threads and Rust compiler stops most data races at compile time
  3. Zero-cost abstractions → You write high-level beautiful code → it runs almost as fast as low-level C

Because of these, many big companies switched parts of their code to Rust: Microsoft, AWS, Google, Meta, Discord, Cloudflare, etc.

Step 2: Hello World — Your first Rust program

First you need Rust installed.

Go here → https://www.rust-lang.org/tools/install Run this command (works on Linux, macOS, Windows with WSL or Git Bash):

Bash

After installation, check:

Bash

You should see something like rustc 1.85.0 or newer (in 2026 probably 1.90+).

Now create first program:

Bash

Open src/main.rs and write:

Rust

Run it:

Bash

Output:

text

cargo run = compile + run Very convenient!

Step 3: Variables & Data Types (very important in Rust)

Rust

Important rules you will love/hate at first:

  • Variables are immutable by default → very good for safety
  • You must write mut when you want to change them

Step 4: Ownership – The famous Rust concept (Chapter 4 in The Book)

This is where most beginners go “😱 what??”

Simple analogy:

Every value in Rust has one owner.

When owner goes out of scope → value is dropped (memory freed automatically).

You can move ownership or borrow it.

Example – move:

Rust

Example – borrow (very common):

Rust

Rules (compiler enforces them):

  • At any time, you can have either:
    • One mutable reference (&mut)
    • OR many immutable references (&)
  • But never both at the same time

This stops data races at compile time — magic!

Step 5: Small but real example — Number Guessing Game

This is the classic example from official Rust Book:

Rust

Add dependency in Cargo.toml:

toml

Then cargo run — enjoy!

Where should you learn properly? (2026 recommendation)

Best free path in 2025–2026:

  1. The Rust Book (official, free, best quality) → https://doc.rust-lang.org/book/
  2. While reading — watch Let’s Get Rusty YouTube videos → Same chapter order, very clear explanations
  3. After ~Chapter 6 do small projects:
    • CLI tool (clap crate)
    • Tiny web server (axum or actix-web)
    • File reader / JSON parser
  4. Extra good resources:
    • Rust by Example → https://doc.rust-lang.org/rust-by-example/
    • Comprehensive Rust (Google) → https://google.github.io/comprehensive-rust/
    • Rustlings (small exercises) → https://github.com/rust-lang/rustlings

Start slow. Rust feels hard for 1–3 weeks → then suddenly clicks and you fall in love 😄

Any chapter or concept you want me to explain next in detail? Ownership again? Structs? Enums? Error handling? Lifetimes? Just tell me — I’m your Rust teacher today! 🚀