Rust for the BenchA two-day Rust crash course built around the PA Test Bench All courses
0 of 15 exercises
Starting…

A two-day crash course

Rust for the Bench

Rust, taught through the same problems the PA Test Bench code solves: drivers, readings that might be missing, limit checks and sweeps. By Sunday evening you can read and write ordinary Rust, understand ownership and borrowing, and use Option, Result and traits the way real Rust code does.

Take the Python course first if you can. This course compares with Python all the way through, and several exercises rewrite functions from the bench code you will already know.

Code runs on the official Rust Playground, so Run and Check need an internet connection and take a few seconds each. In an exercise you write the functions and types; the page adds a main that calls them. Copy gives you the whole program to paste into cargo on your own machine.

There are 8 lessons and 15 exercises, each with a Check, a Hint and the Solution. Progress is kept in this browser.

Saturday: the language

09:00Hello, Rust
Programs, main, let and mut, the basic types, and println! formatting.
50 min
10:00Functions, if and loops
Expressions versus statements, if as a value, loop, while, for over ranges.
55 min
10:55Lunch, away from the screen60 min
11:55Ownership and borrowing
The idea Rust is built on: String versus &str, moves, clones, & and &mut.
65 min
13:10Structs and methods
struct, impl, new, &self and &mut self: a signal generator driver.
60 min

Sunday: types that prevent bugs

09:00Enums, match and Option
Replacing -999.0 and NaN with types: enum, match, Option, if let.
60 min
10:10Errors with Result
Result, the ? operator, parse errors, and writing your own error type.
55 min
11:05Lunch, away from the screen60 min
12:05Collections, iterators and closures
Vec, HashMap, closures, and the iterator chains that replace most loops.
60 min
13:15Traits and the capstone
Traits instead of inheritance, generics and dyn, then a mini test engine.
80 min

Start lesson 1