Welcome to Less 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.
Loops
❱
6.2.1.
for
6.2.2.
loop
6.3.
break and continue
❱
6.3.1.
Skip - Labels
6.4.
Blocks and Scopes
❱
6.4.1.
Scopes and Shadowing
6.5.
Functions
6.6.
Macros
6.7.
Exercise: Collatz Sequence
❱
6.7.1.
Solution
Day 1: Morning (continued)
7.
Welcome
8.
Tuples and Arrays
❱
8.1.
Arrays
8.2.
Tuples
8.3.
Array Iteration
8.4.
Skip - Patterns and Destructuring
8.5.
Skip - Exercise: Nested Arrays
❱
8.5.1.
Skip - Solution
9.
References
❱
9.1.
Shared References
9.2.
Exclusive References
9.3.
Slices: &[T]
9.4.
Strings
9.5.
Exercise: Geometry
❱
9.5.1.
Solution
10.
User-Defined Types
❱
10.1.
Named Structs
10.2.
Tuple Structs
10.3.
Enums
10.4.
Skip - Static
10.5.
Skip - Const
10.6.
Skip - Type Aliases
10.7.
Skip - Exercise: Elevator Events
❱
10.7.1.
Skip - Solution
10.8.
Recap
Day 1: Afternoon
11.
Welcome
12.
Pattern Matching
❱
12.1.
Matching Values
12.2.
Destructuring Structs
12.3.
Destructuring Enums
12.4.
Skip - 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: Morning
14.
Welcome
15.
Macroquad Library
❱
15.1.
Getting Started
15.2.
Exercises
16.
Generics
❱
16.1.
Generic Functions
16.2.
Generic Data Types
16.3.
Generic Traits
16.4.
Trait Bounds
16.5.
impl Trait
16.6.
dyn Trait
16.7.
Exercise: Generic min
❱
16.7.1.
Solution
17.
Standard Library Types
❱
17.1.
Standard Library
17.2.
Documentation
17.3.
Option
17.4.
Result
17.5.
String
17.6.
Vec
17.7.
HashMap
17.8.
Exercise: Counter
❱
17.8.1.
Solution
18.
Standard Library Traits
❱
18.1.
Comparisons
18.2.
Operators
18.3.
From and Into
18.4.
Casting
18.5.
Read and Write
18.6.
Default, struct update syntax
18.7.
Closures
18.8.
Exercise: ROT13
❱
18.8.1.
Solution
Day 3: Morning
19.
Welcome
20.
Memory Management
❱
20.1.
Review of Program Memory
20.2.
Approaches to Memory Management
20.3.
Ownership
20.4.
Move Semantics
20.5.
Clone
20.6.
Copy Types
20.7.
Drop
20.8.
Exercise: Builder Type
❱
20.8.1.
Solution
21.
Smart Pointers
❱
21.1.
Box<T>
21.2.
Rc
21.3.
Owned Trait Objects
21.4.
Exercise: Binary Tree
❱
21.4.1.
Solution
Day 3: Afternoon
22.
Welcome
23.
Borrowing
❱
23.1.
Borrowing a Value
23.2.
Borrow Checking
23.3.
Borrow Errors
23.4.
Interior Mutability
23.5.
Exercise: Health Statistics
❱
23.5.1.
Solution
24.
Lifetimes
❱
24.1.
Lifetime Annotations
24.2.
Lifetime Elision
24.3.
Struct Lifetimes
24.4.
Exercise: Protobuf Parsing
❱
24.4.1.
Solution
Day 4: Morning
25.
Welcome
26.
Iterators
❱
26.1.
Iterator
26.2.
IntoIterator
26.3.
FromIterator
26.4.
Exercise: Iterator Method Chaining
❱
26.4.1.
Solution
27.
Modules
❱
27.1.
Modules
27.2.
Filesystem Hierarchy
27.3.
Visibility
27.4.
use, super, self
27.5.
Exercise: Modules for a GUI Library
❱
27.5.1.
Solution
28.
Testing
❱
28.1.
Test Modules
28.2.
Other Types of Tests
28.3.
Compiler Lints and Clippy
28.4.
Exercise: Luhn Algorithm
❱
28.4.1.
Solution
Day 4: Afternoon
29.
Welcome
30.
Error Handling
❱
30.1.
Panics
30.2.
Result
30.3.
Try Operator
30.4.
Try Conversions
30.5.
Error Trait
30.6.
thiserror and anyhow
30.7.
Exercise: Rewriting with Result
❱
30.7.1.
Solution
31.
Unsafe Rust
❱
31.1.
Unsafe
31.2.
Dereferencing Raw Pointers
31.3.
Mutable Static Variables
31.4.
Unions
31.5.
Unsafe Functions
31.6.
Unsafe Traits
31.7.
Exercise: FFI Wrapper
❱
31.7.1.
Solution
Android
32.
Welcome
33.
Setup
34.
Build Rules
❱
34.1.
Binary
34.2.
Library
35.
AIDL
❱
35.1.
Birthday Service Tutorial
❱
35.1.1.
Interface
35.1.2.
Service API
35.1.3.
Service
35.1.4.
Server
35.1.5.
Deploy
35.1.6.
Client
35.1.7.
Changing API
35.1.8.
Updating Implementations
35.2.
AIDL Types
❱
35.2.1.
Primitive Types
35.2.2.
Array Types
35.2.3.
Sending Objects
35.2.4.
Parcelables
35.2.5.
Sending Files
36.
Testing
❱
36.1.
GoogleTest
36.2.
Mocking
37.
Logging
38.
Interoperability
❱
38.1.
With C
❱
38.1.1.
Calling C with Bindgen
38.1.2.
Calling Rust from C
38.2.
With C++
❱
38.2.1.
The Bridge Module
38.2.2.
Rust Bridge
38.2.3.
Generated C++
38.2.4.
C++ Bridge
38.2.5.
Shared Types
38.2.6.
Shared Enums
38.2.7.
Rust Error Handling
38.2.8.
C++ Error Handling
38.2.9.
Additional Types
38.2.10.
Building for Android: C++
38.2.11.
Building for Android: Genrules
38.2.12.
Building for Android: Rust
38.3.
With Java
39.
Exercises
Chromium
40.
Welcome
41.
Setup
42.
Comparing Chromium and Cargo Ecosystems
43.
Policy
44.
Build Rules
❱
44.1.
Unsafe Code
44.2.
Depending on Rust Code from Chromium C++
44.3.
Visual Studio Code
44.4.
Exercise
45.
Testing
❱
45.1.
rust_gtest_interop Library
45.2.
GN Rules for Rust Tests
45.3.
chromium::import! Macro
45.4.
Exercise
46.
Interoperability with C++
❱
46.1.
Example Bindings
46.2.
Limitations of CXX
46.3.
CXX Error Handling
❱
46.3.1.
Error Handling: QR Example
46.3.2.
Error Handling: PNG Example
46.4.
Using CXX in Chromium
46.5.
Exercise
47.
Adding Third Party Crates
❱
47.1.
Configuring Cargo.toml
47.2.
Configuring gnrt_config.toml
47.3.
Downloading Crates
47.4.
Generating gn Build Rules
47.5.
Resolving Problems
❱
47.5.1.
Build Scripts Which Generate Code
47.5.2.
Build Scripts Which Build C++ or Take Arbitrary Actions
47.6.
Depending on a Crate
47.7.
Reviews and Audits
47.8.
Checking into Chromium Source Code
47.9.
Keeping Crates Up to Date
47.10.
Exercise
48.
Bringing It Together - Exercise
49.
Exercise Solutions
Bare Metal: Morning
50.
Welcome
51.
no_std
❱
51.1.
A Minimal Example
51.2.
alloc
52.
Microcontrollers
❱
52.1.
Raw MMIO
52.2.
PACs
52.3.
HAL Crates
52.4.
Board Support Crates
52.5.
The Type State Pattern
52.6.
embedded-hal
52.7.
probe-rs and cargo-embed
❱
52.7.1.
Debugging
52.8.
Other Projects
53.
Exercises
❱
53.1.
Compass
53.2.
Solutions
Bare Metal: Afternoon
54.
Application Processors
❱
54.1.
Getting Ready to Rust
54.2.
Inline Assembly
54.3.
MMIO
54.4.
Let's Write a UART Driver
❱
54.4.1.
More Traits
54.5.
A Better UART Driver
❱
54.5.1.
Bitflags
54.5.2.
Multiple Registers
54.5.3.
Driver
54.5.4.
Using It
54.6.
Logging
❱
54.6.1.
Using It
54.7.
Exceptions
54.8.
Other Projects
55.
Useful Crates
❱
55.1.
zerocopy
55.2.
aarch64-paging
55.3.
buddy_system_allocator
55.4.
tinyvec
55.5.
spin
56.
Android
❱
56.1.
vmbase
57.
Exercises
❱
57.1.
RTC Driver
57.2.
Solutions
Concurrency: Morning
58.
Welcome
59.
Threads
❱
59.1.
Plain Threads
59.2.
Scoped Threads
60.
Channels
❱
60.1.
Senders and Receivers
60.2.
Unbounded Channels
60.3.
Bounded Channels
61.
Send and Sync
❱
61.1.
Marker Traits
61.2.
Send
61.3.
Sync
61.4.
Examples
62.
Shared State
❱
62.1.
Arc
62.2.
Mutex
62.3.
Example
63.
Exercises
❱
63.1.
Dining Philosophers
63.2.
Multi-threaded Link Checker
63.3.
Solutions
Concurrency: Afternoon
64.
Welcome
65.
Async Basics
❱
65.1.
async/await
65.2.
Futures
65.3.
Runtimes
❱
65.3.1.
Tokio
65.4.
Tasks
66.
Channels and Control Flow
❱
66.1.
Async Channels
66.2.
Join
66.3.
Select
67.
Pitfalls
❱
67.1.
Blocking the Executor
67.2.
Pin
67.3.
Async Traits
67.4.
Cancellation
68.
Exercises
❱
68.1.
Dining Philosophers
68.2.
Broadcast Chat Application
68.3.
Solutions
Final Words
69.
Thanks!
70.
Glossary
71.
Other Resources
72.
Credits
Light
Rust
Coal
Navy
Ayu
Comprehensive Rust 🦀
English
Brazilian Portuguese (Português do Brasil)
Chinese Simplified (汉语)
Chinese Traditional (漢語)
Japanese (日本語)
Korean (한국어)
Spanish (Español)
Useful crates
We’ll go over a few crates which solve some common problems in bare-metal programming.