Module 27 — WebAssembly with Rust
WebAssembly with Rust: wasm-pack, wasm-bindgen, JS interop, performance optimization and deployment. From Rust code to a running Wasm binary in the browser.
27 hands-on Rust modules: ownership, lifetimes, traits, concurrency, async, macros, FFI, WebAssembly. Compile-first learning with worked examples and self-checks.
WebAssembly with Rust: wasm-pack, wasm-bindgen, JS interop, performance optimization and deployment. From Rust code to a running Wasm binary in the browser.
Deep dive: atomic operations, memory orderings, and CAS loops — tools without locks but with sharper contracts. When atomics shine and when the mutex stays.
Deep Dive: egui/eframe for instant UIs — why Immediate Mode fits system languages, State management with Rust's ownership, Layout & Style, Custom painting, and when Retained Mode is the better choice.
Migration, interop & safety guarantees: how to port C++ code to Rust — sum types instead of inheritance, ownership transfer, cxx/bindgen, incremental Ship-of-Theseus migration and verifying what you translated.
AI practice with Rust: typed tensors & inference (candle), tokenizers & text as types, a small inference pipeline, RAG with sum types, and verifying unsafe-led seams with Miri and Kani.
Build your own data types: structs with fields and derives, methods with impl, the newtype pattern — and an inventory as a mini-project.
Variants with data, Option and Result instead of null and exceptions, exhaustive match — and the ?-operator for clean error flows.
Vec, HashMap, and HashSet in practice: growing, safe access, the entry idiom — and anagram groups as a mini-project.
Errors as values: custom error enums, the ? operator, panic vs. Result — and a config parser as a mini-project.
Abstraction without cost: generic functions and types, custom traits with default methods, the std traits everyone knows.
References that live too long? Not possible — the compiler checks each one. Understand lifetimes, use elision, bind structs.
Functions as values: closures with captures, the Iterator trait, adapter chains without intermediate copies — and a log evaluation as a mini-project.
Box, Rc, RefCell: bringing values to the heap, sharing ownership, mutation through shared handles — the tools above the ownership model.
Threads, Channels, Mutex: Rust's ownership rules protect you in parallel too — data races become compile errors.
Everything together: a command-line tool with arguments, file I/O, filtering and sorting — structured, testable, without panic.
Install Rust, understand Cargo, Hello World with real formatting — and the first compile error that makes you better.
Shadowing, scalar and composite types, the tail expression trick, if/match/loop — with runtime panics you can trigger yourself locally.
The heart of Rust: move semantics, the aliasing rule, non-lexical lifetimes, and slices — with every compile error live in the playground.
Crates, packages, modules, and paths: how to structure growing Rust projects. Learn to group code into modules, control visibility, and keep overview with use.
Writing, organizing, and running tests: #[test], assertions, should_panic, unit and integration tests. Learn to secure your program with cargo test and catch bugs early.
Release profiles, custom build config, workspaces for monorepos, documentation, and publishing to crates.io. Learn to use Cargo beyond build & run.
The final project: build a mini-static-site generator in Rust. Combine parsing, rendering, templates, testing, and a workspace binary into a real, fully tested project.
extern blocks, std::ffi types, CString, #[link], and the libgit2 binding: how Rust talks to C libraries. Learn to declare foreign functions, map C types correctly, and build a safe wrapper around raw FFI.
unsafe blocks, unsafe functions, raw pointers, undefined behavior, unsafe traits, and unions: when Rust's safety guarantees aren't enough. Learn when unsafe is necessary, what contracts are, and how to use it safely.
macro_rules!, patterns, expansion, and repetition: how Rust macros work. Learn to write reusable code that expands at compile time — from vec! to your own domain macros.
Readers, Writers, BufRead, files, paths, and networking in Rust: how to read data from any source and write to any destination. Learn the unified Read/Write system where one function works for files, network, and memory alike.
Non-blocking I/O, async tasks, Futures, and Streams: Rust's approach to building highly scalable, concurrent applications. Learn how to serve thousands of connections simultaneously — without data races and without callback hell.