欢迎来到 Comprehensive Rust 🦀
1.
授课
❱
1.1.
课程结构
1.2.
键盘快捷键
1.3.
翻译
2.
使用 Cargo
❱
2.1.
Rust 生态系统
2.2.
代码示例
2.3.
在本地运行 Cargo
第一天:上午
3.
欢迎
4.
Hello, World
❱
4.1.
什么是 Rust?
4.2.
Hello, World
4.3.
Rust 的优势
4.4.
Playground
5.
类型和值
❱
5.1.
变量
5.2.
值
5.3.
算术
5.4.
字符串
5.5.
类型推导
5.6.
练习:Fibonacci
❱
5.6.1.
解答
6.
控制流基础
❱
6.1.
条件控制
6.2.
循环控制
❱
6.2.1.
for
6.2.2.
loop
6.3.
break 和 continue
❱
6.3.1.
Labels
6.4.
代码块和作用域
❱
6.4.1.
作用域和遮蔽(Shadowing)
6.5.
函数
6.6.
宏
6.7.
练习:考拉兹序列
❱
6.7.1.
解答
第一天:下午
7.
欢迎
8.
元组和数组
❱
8.1.
元组和数组
8.2.
数组迭代
8.3.
模式匹配
8.4.
解构
8.5.
练习:嵌套数组
❱
8.5.1.
解答
9.
引用
❱
9.1.
共享引用
9.2.
独占引用
9.3.
练习:几何图形
❱
9.3.1.
解答
10.
用户定义的类型
❱
10.1.
结构体
10.2.
元组结构体
10.3.
枚举
10.4.
静态变量与常量
10.5.
类型别名
10.6.
练习:电梯事件
❱
10.6.1.
解答
第二天:上午
11.
欢迎
12.
模式匹配
❱
12.1.
解构
12.2.
let 控制流
12.3.
练习:表达式求值
❱
12.3.1.
解答
13.
方法和特征
❱
13.1.
方法
13.2.
特征(Trait)
13.3.
派生特征
13.4.
练习:通用日志
❱
13.4.1.
解答
14.
泛型
❱
14.1.
泛型函数
14.2.
泛型类型
14.3.
特征边界
14.4.
impl Trait
14.5.
练习:通用 min 函数
❱
14.5.1.
解答
第二天:下午
15.
欢迎
16.
标准库类型
❱
16.1.
标准库
16.2.
文档
16.3.
Option
16.4.
Result
16.5.
String
16.6.
Vec
16.7.
HashMap
16.8.
练习:计数器
❱
16.8.1.
解答
17.
标准库特征
❱
17.1.
比较
17.2.
运算符
17.3.
From 和 Into
17.4.
类型转换
17.5.
Read 和 Write
17.6.
Default,结构体更新语法
17.7.
闭包
17.8.
练习:ROT13
❱
17.8.1.
解答
第三天:上午
18.
欢迎
19.
内存管理
❱
19.1.
回顾:程序的内存分配
19.2.
内存管理方法
19.3.
所有权
19.4.
移动语义
19.5.
Clone
19.6.
复合类型
19.7.
Drop
19.8.
练习:构建器类型
❱
19.8.1.
解答
20.
智能指针
❱
20.1.
Box
20.2.
Rc
20.3.
特征对象
20.4.
练习:二叉树
❱
20.4.1.
解答
第三天:下午
21.
欢迎
22.
借用
❱
22.1.
借用值
22.2.
借用检查
22.3.
内部可变性
22.4.
练习:健康统计
❱
22.4.1.
解答
23.
切片与生命周期
❱
23.1.
Slices: &[T]
23.2.
字符串引用
23.3.
生命周期注解
23.4.
生命周期省略
23.5.
结构体生命周期
23.6.
练习:Protobuf 解析
❱
23.6.1.
解答
第四天:上午
24.
欢迎
25.
迭代器
❱
25.1.
Iterator
25.2.
IntoIterator
25.3.
FromIterator
25.4.
练习:迭代器方法链
❱
25.4.1.
解答
26.
模块
❱
26.1.
模块
26.2.
文件系统层级结构
26.3.
可见性
26.4.
use、super、self
26.5.
练习:面向 GUI 库的模块
❱
26.5.1.
解答
27.
测试
❱
27.1.
测试模块
27.2.
其他类型的测试
27.3.
实用 Crate
27.4.
GoogleTest
27.5.
模拟
27.6.
编译器 Lint 和 Clippy
27.7.
练习:卢恩算法
❱
27.7.1.
解答
第四天:下午
28.
欢迎
29.
错误处理
❱
29.1.
Panics
29.2.
尝试运算符
29.3.
尝试转换
29.4.
Error 特征
29.5.
thiserror 和 anyhow
29.6.
练习:使用 Result 进行重写
❱
29.6.1.
解答
30.
不安全 Rust
❱
30.1.
Unsafe
30.2.
解引用裸指针
30.3.
可变的静态变量
30.4.
联合体
30.5.
Unsafe 函数
30.6.
Unsafe 特征
30.7.
练习:FFI 封装容器
❱
30.7.1.
解答
Android
31.
欢迎
32.
设置
33.
构建规则
❱
33.1.
可执行文件
33.2.
库
34.
AIDL
❱
34.1.
Birthday Service Tutorial
❱
34.1.1.
接口
34.1.2.
Service API
34.1.3.
Service
34.1.4.
服务器
34.1.5.
部署
34.1.6.
客户端
34.1.7.
更改 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.
日志记录
36.
互操作性
❱
36.1.
与 C 语言交互
❱
36.1.1.
使用 Bindgen 调用 C 语言
36.1.2.
从 C 语言调用 Rust 语言
36.2.
与 C++ 交互
❱
36.2.1.
桥接模块
36.2.2.
Rust 桥接
36.2.3.
生成的 C++ 代码
36.2.4.
C++ 桥接
36.2.5.
共享类型
36.2.6.
共享枚举
36.2.7.
Rust 错误处理
36.2.8.
C++ 错误处理
36.2.9.
其他类型
36.2.10.
为 Android 构建:C++
36.2.11.
为 Android 构建:Genrule
36.2.12.
为 Android 构建:Rust
36.3.
与 Java 交互
37.
习题
Chromium
38.
欢迎
39.
设置
40.
Chromium 和 Cargo 的生态对比
41.
政策
42.
构建规则
❱
42.1.
不安全代码
42.2.
在 Chromium C++ 中导入 Rust 代码
42.3.
Visual Studio Code
42.4.
练习
43.
测试
❱
43.1.
rust_gtest_interop 库
43.2.
Rust 测试的 GN 规则
43.3.
chromium::import! 宏
43.4.
练习
44.
与 C++ 的互操作性
❱
44.1.
绑定示例
44.2.
CXX 的局限性
44.3.
CXX 错误处理
❱
44.3.1.
错误处理:QR 码示例
44.3.2.
错误处理:PNG 示例
44.4.
在 Chromium 中使用 CXX
44.5.
练习
45.
添加第三方 Crate
❱
45.1.
配置 Cargo.toml
45.2.
配置 gnrt_config.toml
45.3.
下载 Crate
45.4.
生成 gn 构建规则
45.5.
解决问题
❱
45.5.1.
构建用于生成代码的脚本
45.5.2.
构建用于构建 C++ 或执行任意操作的脚本
45.6.
依赖于 Crate
45.7.
审查和审核
45.8.
提交到 Chromium 源代码
45.9.
及时更新 Crate
45.10.
练习
46.
综合应用练习
47.
练习解答
裸机:上午
48.
欢迎
49.
no_std
❱
49.1.
最小示例
49.2.
alloc
50.
微控制器
❱
50.1.
原始 MMIO
50.2.
PAC
50.3.
HAL Crate
50.4.
板级支持 Crate
50.5.
类型状态模式
50.6.
embedded-hal
50.7.
probe-rs 和 cargo-embed
❱
50.7.1.
调试
50.8.
其他项目
51.
习题
❱
51.1.
罗盘
51.2.
解答
裸机:下午
52.
应用处理器
❱
52.1.
准备使用 Rust
52.2.
内联汇编
52.3.
MMIO
52.4.
编写 UART 驱动程序
❱
52.4.1.
更多特征
52.5.
优化 UART 驱动程序
❱
52.5.1.
Bitflags
52.5.2.
多寄存器
52.5.3.
驱动程序
52.5.4.
开始使用
52.6.
日志记录
❱
52.6.1.
开始使用
52.7.
异常
52.8.
其他项目
53.
实用 Crate
❱
53.1.
zerocopy
53.2.
aarch64-paging
53.3.
buddy_system_allocator
53.4.
tinyvec
53.5.
spin
54.
Android
❱
54.1.
vmbase
55.
习题
❱
55.1.
RTC 驱动
55.2.
解答
并发:上午
56.
欢迎
57.
线程
❱
57.1.
范围线程
58.
通道
❱
58.1.
无界通道
58.2.
有界通道
59.
Send 和 Sync
❱
59.1.
Send
59.2.
Sync
59.3.
示例
60.
共享状态
❱
60.1.
Arc
60.2.
互斥器(Mutex)
60.3.
示例
61.
习题
❱
61.1.
哲学家就餐问题
61.2.
多线程链接检查器
61.3.
解答
并发:下午
62.
异步基础
❱
62.1.
async/await
62.2.
Futures
62.3.
Runtimes
❱
62.3.1.
Tokio
62.4.
任务
62.5.
异步通道
63.
控制流
❱
63.1.
加入
63.2.
选择
64.
误区
❱
64.1.
阻塞执行器
64.2.
Pin
64.3.
异步特征
64.4.
消除
65.
习题
❱
65.1.
哲学家就餐问题
65.2.
广播聊天应用
65.3.
解答
结束语
66.
谢谢!
67.
词汇表
68.
其他资源
69.
鸣谢
Light
Rust
Coal
Navy
Ayu
Comprehensive Rust 🦀
English
Brazilian Portuguese (Português do Brasil)
Chinese Simplified (汉语)
Chinese Traditional (漢語)
Korean (한국어)
Spanish (Español)
习题
我们将为 PL031 实时时钟设备编写驱动程序。
After looking at the exercises, you can look at the
solutions
provided.