Rust fundamentals
You learn Rust, which enforces memory safety at compile time, from scratch, set up projects with cargo and write small, solid programs by reading the compiler's error messages.
Level 101 · 18 lessons · 15 practice labs
Lessons
Getting started
- Why Rust exists: memory safety and speed
- Your first project with cargo: new, build, run
- Variables, immutability and shadowing
- Numeric types, overflow and type conversion
- String and &str: two kinds of text
- Short task: a temperature converter
Flow and data
- if, loop, while and for
- Functions, expressions and statements
- Structs and methods
- enum and match: handling every case
- Vec and HashMap
- Short task: word frequency in a file
Errors and modules
- Option and Result: no null and no exceptions
- Propagating errors with the ? operator
- Modules, crates and visibility
- cargo test, clippy and rustfmt
- Short task: a key=value configuration reader
Capstone
- Capstone: a Rust tool that summarises a log file
Practice labs
- Converting sensor readings from integers to floats: Convert i32 readings given in tenths of a degree into f64 degrees and pass the tests that use random values.
- Preventing overflow in a stock counter: Protect Kestane Market's u32 stock counter against overflow and going below zero with checked_add and checked_sub.
- Safe conversion with TryFrom instead of as: Replace silently truncating as casts with TryFrom and pass the tests that check errors at boundary values.
- Building initials from a full name: Return the initials of a full name given as &str as a String, working correctly for names with Turkish letters.
- Making a URL slug from a title: Write a function that turns a news headline into a lower-case, hyphenated slug and passes the whitespace and punctuation tests.
- Truncating text safely on a character boundary: Fix a truncation function that panics on byte slicing by using char_indices, and pass the tests with multi-byte characters.
- Classifying parcel size with an enum: Write an enum and a match that return Small, Medium or Large by weight for Sarıkız Kargo.
- Modelling traffic light states: Compute a traffic light's next state and wait time using an enum that carries data and impl blocks.
- Parsing text commands into an enum: Turn commands such as "add 3" and "del 2" into a Command enum using match guards and nested patterns, returning errors for invalid input.
- Finding the top three scores: Return the three highest scores from a Vec<u32> in order, supporting lists with fewer than three items.
- Counting library visits per branch: Use a HashMap and the entry API to count visits per branch from Çınaraltı Library's entry records.
- Grouping staff by department: Group a staff list by department, sort each group by name and return the output in a deterministic order.
- Looking up a user with Option: Write a user lookup by id that returns Option instead of a sentinel and test the not-found case.
- Simplifying an error chain with the ? operator: Rewrite a file-reading function full of nested matches using the ? operator, keeping behaviour and tests unchanged.
- Splitting a single-file tool into modules: Split a tool living in one main.rs into parse and report modules, fix visibility and get cargo clippy to pass with no warnings.
About this course
You learn Rust, which enforces memory safety at compile time, from scratch, set up projects with cargo and write small, solid programs by reading the compiler's error messages.
What you will learn
- Getting started
- Flow and data
- Errors and modules
- Capstone
Prerequisites
No prior knowledge is needed; the course starts from zero.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at beginner level; every term is explained where it first appears.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.