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.
Benefits of Rust
4.3.
Playground
5.
Types and Values
❱
5.1.
Hello, World
5.2.
Variables
5.3.
Values
5.4.
Arithmetic
5.5.
Type Inference
5.6.
Exercise: Fibonacci
❱
5.6.1.
Solution
6.
Control Flow Basics
❱
6.1.
if Expressions
6.2.
match Expressions
6.3.
Loops
❱
6.3.1.
for
6.3.2.
loop
6.4.
break and continue
❱
6.4.1.
Labels
6.5.
Blocks and Scopes
❱
6.5.1.
Scopes and Shadowing
6.6.
Functions
6.7.
Macros
6.8.
Exercise: Collatz Sequence
❱
6.8.1.
Solution
Day 1: Afternoon
7.
Welcome
8.
Tuples and Arrays
❱
8.1.
Arrays
8.2.
Tuples
8.3.
Array Iteration
8.4.
Patterns and Destructuring
8.5.
Exercise: Nested Arrays
❱
8.5.1.
Solution
9.
References
❱
9.1.
Shared References
9.2.
Exclusive References
9.3.
Slices
9.4.
Strings
9.5.
Reference Validity
9.6.
Exercise: Geometry
❱
9.6.1.
Solution
10.
User-Defined Types
❱
10.1.
Named Structs
10.2.
Tuple Structs
10.3.
Enums
10.4.
Const
10.5.
Static
10.6.
Type Aliases
10.7.
Exercise: Elevator Events
❱
10.7.1.
Solution
Day 2: Morning
11.
Welcome
12.
Pattern Matching
❱
12.1.
Matching Values
12.2.
Destructuring Structs
12.3.
Destructuring Enums
12.4.
Let Control Flow
12.5.
Exercise: Expression Evaluation
❱
12.5.1.
Solution
13.
Methods and Traits
❱
13.1.
Methods
13.2.
Traits
❱
13.2.1.
Implementing Traits
13.2.2.
Supertraits
13.2.3.
Associated Types
13.3.
Deriving
13.4.
Exercise: Generic Logger
❱
13.4.1.
Solution
Day 2: Afternoon
14.
Welcome
15.
Generics
❱
15.1.
Generic Functions
15.2.
Generic Data Types
15.3.
Generic Traits
15.4.
Trait Bounds
15.5.
impl Trait
15.6.
dyn Trait
15.7.
Exercise: Generic min
❱
15.7.1.
Solution
16.
Standard Library Types
❱
16.1.
Standard Library
16.2.
Documentation
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<T>
20.2.
Rc
20.3.
Owned Trait Objects
20.4.
Exercise: Binary Tree
❱
20.4.1.
Solution
Day 3: Afternoon
21.
Welcome
22.
Borrowing
❱
22.1.
Borrowing a Value
22.2.
Borrow Checking
22.3.
Borrow Errors
22.4.
Interior Mutability
22.5.
Exercise: Health Statistics
❱
22.5.1.
Solution
23.
Lifetimes
❱
23.1.
Lifetime Annotations
23.2.
Lifetime Elision
23.3.
Struct Lifetimes
23.4.
Exercise: Protobuf Parsing
❱
23.4.1.
Solution
Day 4: Morning
24.
Welcome
25.
Iterators
❱
25.1.
Motivation
25.2.
Iterator Trait
25.3.
Iterator Helper Methods
25.4.
collect
25.5.
IntoIterator
25.6.
Exercise: Iterator Method Chaining
❱
25.6.1.
Solution
26.
Modules
❱
26.1.
Modules
26.2.
Filesystem Hierarchy
26.3.
Visibility
26.4.
Encapsulation
26.5.
use, super, self
26.6.
Exercise: Modules for a GUI Library
❱
26.6.1.
Solution
27.
Testing
❱
27.1.
Unit Tests
27.2.
Other Types of Tests
27.3.
Compiler Lints and Clippy
27.4.
Exercise: Luhn Algorithm
❱
27.4.1.
Solution
Day 4: Afternoon
28.
Welcome
29.
Error Handling
❱
29.1.
Panics
29.2.
Result
29.3.
Try Operator
29.4.
Try Conversions
29.5.
Error Trait
29.6.
thiserror
29.7.
anyhow
29.8.
Exercise: Rewriting with Result
❱
29.8.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.
Birthday Service Tutorial
❱
34.1.1.
Interface
34.1.2.
Service API
34.1.3.
Service
34.1.4.
Server
34.1.5.
Deploy
34.1.6.
Client
34.1.7.
Changing API
34.1.8.
Updating Implementations
34.2.
AIDL Types
❱
34.2.1.
Primitive Types
34.2.2.
Array Types
34.2.3.
Sending Objects
34.2.4.
Parcelables
34.2.5.
Sending Files
35.
Testing
❱
35.1.
GoogleTest
35.2.
Mocking
36.
Logging
37.
Interoperability
❱
37.1.
With C
❱
37.1.1.
Calling C with Bindgen
37.1.2.
Calling Rust from C
37.2.
With C++
❱
37.2.1.
The Bridge Module
37.2.2.
Rust Bridge
37.2.3.
Generated C++
37.2.4.
C++ Bridge
37.2.5.
Shared Types
37.2.6.
Shared Enums
37.2.7.
Rust Error Handling
37.2.8.
C++ Error Handling
37.2.9.
Additional Types
37.2.10.
Building for Android: C++
37.2.11.
Building for Android: Genrules
37.2.12.
Building for Android: Rust
37.3.
With Java
Chromium
38.
Welcome
39.
Setup
40.
Comparing Chromium and Cargo Ecosystems
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.
Testing
❱
43.1.
rust_gtest_interop Library
43.2.
GN Rules for Rust Tests
43.3.
chromium::import! Macro
43.4.
Exercise
44.
Interoperability with C++
❱
44.1.
Example Bindings
44.2.
Limitations of CXX
44.3.
CXX Error Handling
❱
44.3.1.
Error Handling: QR Example
44.3.2.
Error Handling: PNG Example
44.4.
Using CXX in Chromium
44.5.
Exercise
45.
Adding Third Party Crates
❱
45.1.
Configuring Cargo.toml
45.2.
Configuring gnrt_config.toml
45.3.
Downloading Crates
45.4.
Generating gn Build Rules
45.5.
Resolving Problems
❱
45.5.1.
Build Scripts Which Generate Code
45.5.2.
Build Scripts Which Build C++ or Take Arbitrary Actions
45.6.
Depending on a Crate
45.7.
Reviews and Audits
45.8.
Checking into Chromium Source Code
45.9.
Keeping Crates Up to Date
45.10.
Exercise
46.
Bringing It Together - Exercise
47.
Exercise Solutions
Bare Metal: Morning
48.
Welcome
49.
no_std
❱
49.1.
A Minimal Example
49.2.
alloc
50.
Microcontrollers
❱
50.1.
Raw MMIO
50.2.
PACs
50.3.
HAL Crates
50.4.
Board Support Crates
50.5.
The Type State Pattern
50.6.
embedded-hal
50.7.
probe-rs and cargo-embed
❱
50.7.1.
Debugging
50.8.
Other Projects
51.
Exercises
❱
51.1.
Compass
51.2.
Solutions
Bare Metal: Afternoon
52.
Application Processors
❱
52.1.
Getting Ready to Rust
52.2.
Inline Assembly
52.3.
MMIO
52.4.
Let's Write a UART Driver
❱
52.4.1.
More Traits
52.5.
A Better UART Driver
❱
52.5.1.
Bitflags
52.5.2.
Multiple Registers
52.5.3.
Driver
52.5.4.
Using It
52.6.
Logging
❱
52.6.1.
Using It
52.7.
Exceptions
52.8.
Other Projects
53.
Useful Crates
❱
53.1.
zerocopy
53.2.
aarch64-paging
53.3.
buddy_system_allocator
53.4.
tinyvec
53.5.
spin
54.
Bare-Metal on Android
❱
54.1.
vmbase
55.
Exercises
❱
55.1.
RTC Driver
55.2.
Solutions
Concurrency: Morning
56.
Welcome
57.
Threads
❱
57.1.
Plain Threads
57.2.
Scoped Threads
58.
Channels
❱
58.1.
Senders and Receivers
58.2.
Unbounded Channels
58.3.
Bounded Channels
59.
Send and Sync
❱
59.1.
Marker Traits
59.2.
Send
59.3.
Sync
59.4.
Examples
60.
Shared State
❱
60.1.
Arc
60.2.
Mutex
60.3.
Example
61.
Exercises
❱
61.1.
Dining Philosophers
61.2.
Multi-threaded Link Checker
61.3.
Solutions
Concurrency: Afternoon
62.
Welcome
63.
Async Basics
❱
63.1.
async/await
63.2.
Futures
63.3.
Runtimes
❱
63.3.1.
Tokio
63.4.
Tasks
64.
Channels and Control Flow
❱
64.1.
Async Channels
64.2.
Join
64.3.
Select
65.
Pitfalls
❱
65.1.
Blocking the Executor
65.2.
Pin
65.3.
Async Traits
65.4.
Cancellation
66.
Exercises
❱
66.1.
Dining Philosophers
66.2.
Broadcast Chat Application
66.3.
Solutions
Final Words
67.
Thanks!
68.
Glossary
69.
Other Resources
70.
Credits
Light
Rust
Coal
Navy
Ayu
Comprehensive Rust 🦀
English
Brazilian Portuguese (Português do Brasil)
Chinese Simplified (汉语)
Chinese Traditional (漢語)
Japanese (日本語)
Korean (한국어)
Farsi (فارسی)
Spanish (Español)
Ukrainian (українська)
Exercise Solutions
Solutions to the Chromium exercises can be found in
this series of CLs
.