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
4.
Hello, World
❱
4.1.
What is Rust?
4.2.
Hello, World
4.3.
Benefits of Rust
4.4.
Playground
5.
Types and Values
❱
5.1.
Variables
5.2.
Values
5.3.
Arithmetic
5.4.
Strings
5.5.
Type Inference
5.6.
Exercise: Fibonacci
❱
5.6.1.
Solution
6.
Control Flow Basics
❱
6.1.
Conditionals
6.2.
Loops
6.3.
break and continue
6.4.
Blocks and Scopes
6.5.
Functions
6.6.
Macros
6.7.
Exercise: Collatz conjecture
❱
6.7.1.
Solution
Day 1: Afternoon
7.
Welcome
8.
Tuples and Arrays
❱
8.1.
Tuples and Arrays
8.2.
Array Iteration
8.3.
Pattern Matching
8.4.
Destructuring
8.5.
Exercise: Nested Arrays
❱
8.5.1.
Solution
9.
References
❱
9.1.
Shared References
9.2.
Exclusive References
9.3.
Exercise: Geometry
❱
9.3.1.
Solution
10.
User-Defined Types
❱
10.1.
Named Structs
10.2.
Tuple Structs
10.3.
Enums
10.4.
Static and Const
10.5.
Type Aliases
10.6.
Exercise: Elevator Events
❱
10.6.1.
Solution
Day 2: Morning
11.
Welcome
12.
Pattern Matching
❱
12.1.
Destructuring
12.2.
Let Control Flow
12.3.
Exercise: Expression Evaluation
❱
12.3.1.
Solution
13.
Methods and Traits
❱
13.1.
Methods
13.2.
Traits
13.3.
Deriving
13.4.
Trait Objects
13.5.
Exercise: GUI Library
❱
13.5.1.
Solution
14.
Generics
❱
14.1.
Generic Functions
14.2.
Generic Data types
14.3.
Trait Bounds
14.4.
Impl Trait
14.5.
Exercise: Generic min
❱
14.5.1.
Solution
Day 2: Afternoon
15.
Welcome
16.
Standard Library Types
❱
16.1.
Standard Library
16.2.
Language Docs
16.3.
Option
16.4.
Result
16.5.
String
16.6.
Vec
16.7.
HashMap
16.8.
Exercise: Counter
❱
16.8.1.
Solution
17.
Standard Library Traits
❱
17.1.
Comparisons
17.2.
Operators
17.3.
From and Into
17.4.
Casting
17.5.
Read and Write
17.6.
Default, struct update syntax
17.7.
Closures
17.8.
Exercise: ROT13
❱
17.8.1.
Solution
Day 3: Morning
18.
Welcome
19.
Memory Management
❱
19.1.
Review of Program Memory
19.2.
Approaches to Memory Management
19.3.
Ownership
19.4.
Move semantics
19.5.
Clone
19.6.
Copy Types
19.7.
Drop
19.8.
Exercise: Builder Type
❱
19.8.1.
Solution
20.
Smart Pointers
❱
20.1.
Box
20.2.
Rc
20.3.
Exercise: Binary Tree
❱
20.3.1.
Solution
Day 3: Afternoon
21.
Welcome
22.
Borrowing
❱
22.1.
Borrowing a Value
22.2.
Borrow Checking
22.3.
Interior Mutability
22.4.
Exercise: Health Statistics
❱
22.4.1.
Solution
23.
Slices and Lifetimes
❱
23.1.
Slices: &[T]
23.2.
String References
23.3.
Lifetime Annotations
23.4.
Lifetime Elision
23.5.
Struct Lifetimes
23.6.
Exercise: Protobuf Parsing
❱
23.6.1.
Solution
Day 4: Morning
24.
Welcome
25.
Iterators
❱
25.1.
Iterators
25.2.
IntoIterator
25.3.
FromIterator
25.4.
Exercise: Iterator Method Chaining
❱
25.4.1.
Solution
26.
Modules
❱
26.1.
Modules
26.2.
Filesystem Hierarchy
26.3.
Visibility
26.4.
use, super, self
26.5.
Exercise: Modules for the GUI Library
❱
26.5.1.
Solution
27.
Testing
❱
27.1.
Test Modules
27.2.
Other Types of Tests
27.3.
Useful Crates
27.4.
Compiler lints and Clippy
27.5.
Exercise: Luhn Algorithm
❱
27.5.1.
Solution
Day 4: Afternoon
28.
Welcome
29.
Error Handling
❱
29.1.
Panics
29.2.
Try operator
29.3.
Try Conversions
29.4.
Error Trait
29.5.
thiserror and anyhow
29.6.
Exercise: Rewriting with Result
❱
29.6.1.
Solution
30.
Unsafe Rust
❱
30.1.
Unsafe
30.2.
Dereferencing Raw Pointers
30.3.
Mutable Static Variables
30.4.
Unions
30.5.
Unsafe Functions
30.6.
Unsafe Traits
30.7.
Exercise: FFI Wrapper
❱
30.7.1.
Solution
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.2.1.
The Bridge Module
36.2.2.
Rust Bridge
36.2.3.
Generated C++
36.2.4.
C++ Bridge
36.2.5.
Shared Types
36.2.6.
Shared Enums
36.2.7.
Rust Error Handling
36.2.8.
C++ Error Handling
36.2.9.
Additional Types
36.2.10.
Building for Android: C++
36.2.11.
Building for Android: Genrules
36.2.12.
Building for Android: Rust
36.3.
With Java
37.
Exercises
Chromium
38.
Welcome
39.
Setup
40.
Using cargo for experimental tools
41.
Policy
42.
Build Rules
❱
42.1.
Unsafe code
42.2.
Depending on Rust code from Chromium C++
42.3.
Visual Studio code
42.4.
Exercise
43.
Interoperability with C++
❱
43.1.
Example bindings
43.2.
Limitations of cxx
43.3.
cxx error handling
43.4.
Using cxx in Chromium
43.5.
Exercise
44.
Adding third party crates
❱
44.1.
Configuring Cargo.toml
44.2.
Configuring gnrt_config.toml
44.3.
Downloading crates
44.4.
Generating gn build rules
44.5.
Resolving problems
❱
44.5.1.
Build scripts which generate code
44.5.2.
Build scripts which build C++ or take arbitrary actions
44.6.
Depending on a crate
44.7.
Reviews and audits
44.8.
Checking into Chromium source code
44.9.
Keeping crates up to date
44.10.
Exercise
45.
Bringing it together - Exercise
Bare Metal: Morning
46.
Welcome
47.
no_std
❱
47.1.
A Minimal Example
47.2.
alloc
48.
Microcontrollers
❱
48.1.
Raw MMIO
48.2.
PACs
48.3.
HAL Crates
48.4.
Board Support Crates
48.5.
The Type State Pattern
48.6.
embedded-hal
48.7.
probe-rs, cargo-embed
❱
48.7.1.
Debugging
48.8.
Other Projects
49.
Exercises
❱
49.1.
Compass
49.2.
Solutions
Bare Metal: Afternoon
50.
Application Processors
❱
50.1.
Getting Ready to Rust
50.2.
Inline Assembly
50.3.
MMIO
50.4.
Let's Write a UART Driver
❱
50.4.1.
More Traits
50.5.
A Better UART Driver
❱
50.5.1.
Bitflags
50.5.2.
Multiple Registers
50.5.3.
Driver
50.5.4.
Using It
50.6.
Logging
❱
50.6.1.
Using It
50.7.
Exceptions
50.8.
Other Projects
51.
Useful Crates
❱
51.1.
zerocopy
51.2.
aarch64-paging
51.3.
buddy_system_allocator
51.4.
tinyvec
51.5.
spin
52.
Android
❱
52.1.
vmbase
53.
Exercises
❱
53.1.
RTC Driver
53.2.
Solutions
Concurrency: Morning
54.
Welcome
55.
Threads
❱
55.1.
Scoped Threads
56.
Channels
❱
56.1.
Unbounded Channels
56.2.
Bounded Channels
57.
Send and Sync
❱
57.1.
Send
57.2.
Sync
57.3.
Examples
58.
Shared State
❱
58.1.
Arc
58.2.
Mutex
58.3.
Example
59.
Exercises
❱
59.1.
Dining Philosophers
59.2.
Multi-threaded Link Checker
59.3.
Solutions
Concurrency: Afternoon
60.
Async Basics
❱
60.1.
async/await
60.2.
Futures
60.3.
Runtimes
❱
60.3.1.
Tokio
60.4.
Tasks
60.5.
Async Channels
61.
Control Flow
❱
61.1.
Join
61.2.
Select
62.
Pitfalls
❱
62.1.
Blocking the Executor
62.2.
Pin
62.3.
Async Traits
62.4.
Cancellation
63.
Exercises
❱
63.1.
Dining Philosophers
63.2.
Broadcast Chat Application
63.3.
Solutions
Final Words
64.
Thanks!
65.
Glossary
66.
Other Resources
67.
Credits
Light
Rust
Coal
Navy
Ayu
Comprehensive Rust 🦀
English
Brazilian Portuguese (Português do Brasil)
Chinese Simplified (汉语)
Chinese Traditional (漢語)
Korean (한국어)
Spanish (Español)
Useful crates
We’ll go over a few crates which solve some common problems in bare-metal programming.