Welcome to Comprehensive Rust 🦀
1.
Running the Course
❱
1.1.
Course Structure
1.2.
Keyboard Shortcuts
1.3.
Translations
2.
Using Cargo
❱
2.1.
Rust Ecosystem
2.2.
Code Samples
2.3.
Running Cargo Locally
Day 1: Morning
3.
Welcome
❱
3.1.
What is Rust?
4.
Hello World!
❱
4.1.
Small Example
5.
Why Rust?
❱
5.1.
Compile Time Guarantees
5.2.
Runtime Guarantees
5.3.
Modern Features
6.
Basic Syntax
❱
6.1.
Scalar Types
6.2.
Compound Types
6.3.
References
❱
6.3.1.
Dangling References
6.4.
Slices
❱
6.4.1.
String vs str
6.5.
Functions
❱
6.5.1.
Rustdoc
6.5.2.
Methods
6.5.3.
Overloading
7.
Exercises
❱
7.1.
Implicit Conversions
7.2.
Arrays and for Loops
Day 1: Afternoon
8.
Variables
❱
8.1.
Type Inference
8.2.
static & const
8.3.
Scopes and Shadowing
9.
Memory Management
❱
9.1.
Stack vs Heap
9.2.
Stack Memory
9.3.
Manual Memory Management
9.4.
Scope-Based Memory Management
9.5.
Garbage Collection
9.6.
Rust Memory Management
9.7.
Comparison
10.
Ownership
❱
10.1.
Move Semantics
10.2.
Moved Strings in Rust
❱
10.2.1.
Double Frees in Modern C++
10.3.
Moves in Function Calls
10.4.
Copying and Cloning
10.5.
Borrowing
❱
10.5.1.
Shared and Unique Borrows
10.6.
Lifetimes
10.7.
Lifetimes in Function Calls
10.8.
Lifetimes in Data Structures
11.
Exercises
❱
11.1.
Designing a Library
11.2.
Iterators and Ownership
Day 2: Morning
12.
Welcome
13.
Structs
❱
13.1.
Tuple Structs
13.2.
Field Shorthand Syntax
14.
Enums
❱
14.1.
Variant Payloads
14.2.
Enum Sizes
15.
Methods
❱
15.1.
Method Receiver
15.2.
Example
16.
Pattern Matching
❱
16.1.
Destructuring Enums
16.2.
Destructuring Structs
16.3.
Destructuring Arrays
16.4.
Match Guards
17.
Exercises
❱
17.1.
Health Statistics
17.2.
Points and Polygons
Day 2: Afternoon
18.
Control Flow
❱
18.1.
Blocks
18.2.
if expressions
18.3.
if let expressions
18.4.
while expressions
18.5.
while let expressions
18.6.
for expressions
18.7.
loop expressions
18.8.
match expressions
18.9.
break & continue
19.
Standard Library
❱
19.1.
Option and Result
19.2.
String
19.3.
Vec
19.4.
HashMap
19.5.
Box
❱
19.5.1.
Recursive Data Types
19.5.2.
Niche Optimization
19.6.
Rc
20.
Modules
❱
20.1.
Visibility
20.2.
Paths
20.3.
Filesystem Hierarchy
21.
Exercises
❱
21.1.
Luhn Algorithm
21.2.
Strings and Iterators
Day 3: Morning
22.
Welcome
23.
Generics
❱
23.1.
Generic Data Types
23.2.
Generic Methods
23.3.
Monomorphization
24.
Traits
❱
24.1.
Trait Objects
24.2.
Deriving Traits
24.3.
Default Methods
24.4.
Trait Bounds
24.5.
impl Trait
25.
Important Traits
❱
25.1.
Iterator
25.2.
FromIterator
25.3.
From and Into
25.4.
Read and Write
25.5.
Drop
25.6.
Default
25.7.
Operators: Add, Mul, ...
25.8.
Closures: Fn, FnMut, FnOnce
26.
Exercises
❱
26.1.
A Simple GUI Library
Day 3: Afternoon
27.
Error Handling
❱
27.1.
Panics
❱
27.1.1.
Catching Stack Unwinding
27.2.
Structured Error Handling
27.3.
Propagating Errors with ?
❱
27.3.1.
Converting Error Types
❱
27.3.1.1.
Example
27.3.2.
Deriving Error Enums
27.3.3.
Dynamic Error Types
27.3.4.
Adding Context to Errors
28.
Testing
❱
28.1.
Unit Tests
28.2.
Test Modules
28.3.
Documentation Tests
28.4.
Integration Tests
28.5.
Useful crates
29.
Unsafe Rust
❱
29.1.
Dereferencing Raw Pointers
29.2.
Mutable Static Variables
29.3.
Unions
29.4.
Calling Unsafe Functions
❱
29.4.1.
Writing Unsafe Functions
29.4.2.
Extern Functions
29.5.
Implementing Unsafe Traits
30.
Exercises
❱
30.1.
Safe FFI Wrapper
Android
31.
Welcome
32.
Setup
33.
Build Rules
❱
33.1.
Binary
33.2.
Library
34.
AIDL
❱
34.1.
Interface
34.2.
Implementation
34.3.
Server
34.4.
Deploy
34.5.
Client
34.6.
Changing API
35.
Logging
36.
Interoperability
❱
36.1.
With C
❱
36.1.1.
Calling C with Bindgen
36.1.2.
Calling Rust from C
36.2.
With C++
36.3.
With Java
37.
Exercises
Bare Metal: Morning
38.
Welcome
39.
no_std
❱
39.1.
A Minimal Example
39.2.
alloc
40.
Microcontrollers
❱
40.1.
Raw MMIO
40.2.
PACs
40.3.
HAL Crates
40.4.
Board Support Crates
40.5.
The Type State Pattern
40.6.
embedded-hal
40.7.
probe-rs, cargo-embed
❱
40.7.1.
Debugging
40.8.
Other Projects
41.
Exercises
❱
41.1.
Compass
Bare Metal: Afternoon
42.
Application Processors
❱
42.1.
Inline Assembly
42.2.
MMIO
42.3.
Let's Write a UART Driver
❱
42.3.1.
More Traits
42.4.
A Better UART Driver
❱
42.4.1.
Bitflags
42.4.2.
Multiple Registers
42.4.3.
Driver
42.4.4.
Using It
42.5.
Logging
❱
42.5.1.
Using It
42.6.
Other Projects
43.
Useful Crates
❱
43.1.
zerocopy
43.2.
aarch64-paging
43.3.
buddy_system_allocator
43.4.
tinyvec
43.5.
spin
44.
Android
❱
44.1.
vmbase
45.
Exercises
❱
45.1.
RTC Driver
Concurrency: Morning
46.
Welcome
47.
Threads
❱
47.1.
Scoped Threads
48.
Channels
❱
48.1.
Unbounded Channels
48.2.
Bounded Channels
49.
Send and Sync
❱
49.1.
Send
49.2.
Sync
49.3.
Examples
50.
Shared State
❱
50.1.
Arc
50.2.
Mutex
50.3.
Example
51.
Exercises
❱
51.1.
Dining Philosophers
51.2.
Multi-threaded Link Checker
Concurrency: Afternoon
52.
Async Basics
❱
52.1.
async/await
52.2.
Futures
52.3.
Runtimes
❱
52.3.1.
Tokio
52.4.
Tasks
52.5.
Async Channels
53.
Control Flow
❱
53.1.
Join
53.2.
Select
54.
Pitfalls
❱
54.1.
Blocking the Executor
54.2.
Pin
54.3.
Async Traits
55.
Exercises
❱
55.1.
Dining Philosophers
55.2.
Broadcast Chat Application
Final Words
56.
Thanks!
57.
Other Resources
58.
Credits
Solutions
59.
Solutions
❱
59.1.
Day 1 Morning
59.2.
Day 1 Afternoon
59.3.
Day 2 Morning
59.4.
Day 2 Afternoon
59.5.
Day 3 Morning
59.6.
Day 3 Afternoon
59.7.
Bare Metal Rust Morning
59.8.
Bare Metal Rust Afternoon
59.9.
Concurrency Morning
59.10.
Concurrency Afternoon
Light
Rust
Coal
Navy
Ayu
Comprehensive Rust 🦀
English
Brazilian Portuguese
한국어 (Korean)
Useful crates
We’ll go over a few crates which solve some common problems in bare-metal programming.