R

rust.quest

Master Rust through interactive, visual learning

cargo run -- welcome
$ cargo run
Compiling rust_quest v1.0.0
Finished dev [unoptimized + debuginfo]
Running `target/debug/rust_quest`
Welcome to rust.quest — your journey begins here.
$ _
Begin Your Quest
Chapter 01

Ownership

Rust's most unique feature — understanding who owns what

ownership.rs
fn main() {
    let s1 = String::from("hello");
    let s2 = s1; // s1 moved to s2

    // println!("{}", s1); // ERROR!
    println!("{}", s2); // OK
}

Memory Model

When s1 is assigned to s2, ownership moves. Only one owner at a time.

Chapter 02

Borrowing

References let you use data without taking ownership

Borrowing Rules

borrowing.rs
fn main() {
    let mut s = String::from("hello");

    // Multiple immutable borrows: OK
    let r1 = &s;
    let r2 = &s;
    println!("{}, {}", r1, r2);

    // Mutable borrow: exclusive
    let r3 = &mut s;
    r3.push_str(", world");
    println!("{}", r3);
}
Chapter 03

Lifetimes

Ensuring references are always valid

lifetimes.rs
fn longest<'a>(
    x: &'a str,
    y: &'a str,
) -> &'a str {
    if x.len() > y.len() { x }
    else { y }
}

fn main() {
    let s1 = String::from("long string");
    let result;
    {
        let s2 = String::from("xyz");
        result = longest(&s1, &s2);
        println!("{}", result);
    }
}

Lifetime Scopes

Chapter 04

Zero-Cost Abstractions

High-level code, low-level performance

Runtime Performance

Rust
~1.0x
C
~1.0x
Go
~1.7x
Java
~2.4x
Python
~75x

Relative execution time (lower is faster)

Memory Safety Without GC

No null pointers
No data races
No use-after-free
No buffer overflows
No garbage collector
Compile-time checks
next_steps.rs
$ rustup update
info: syncing channel updates
stable-x86_64 updated - rustc 1.82.0
$ cargo new my_project
Created binary (application) `my_project` package
$ _

Ready to Build?

Start your Rust journey today. Zero-cost abstractions, memory safety without garbage collection, and fearless concurrency await.