资源推荐

按学习阶段分类的 Rust 学习资源

标注 ★ 的为强烈推荐


一、书籍

入门阶段 (第 1-3 章)

书名作者推荐程度链接
★ The Rust Programming Language (TRPL)Steve Klabnik必读在线免费
Rust by ExampleRust Team配合TRPL在线免费
RustlingsRust Team动手练习GitHub

进阶阶段 (第 4-7 章)

书名作者推荐程度说明
★ Programming Rust (2nd)Blandy & Orendorff深度理解最好的 Rust 书, 有中文版
Rust for RustaceansJon Gjengset进阶必读讲解 Rust 的”为什么”
The RustonomiconRust Teamunsafe 专项在线免费

专题书籍

书名专题推荐程度
★ Rust Atomics and Locks并发/内存模型Mara Bos 著, 在线免费
Zero to Production in RustWeb 开发Actix/Axum 生态
Rust in Action系统编程Tim McNamara 著
Learn Rust with Entirely Too Many Linked Listsunsafe + 数据结构在线免费

二、官方文档

文档链接核心内容
★ 标准库文档doc.rust-lang.org/std查 API 必备
Edition Guidedoc.rust-lang.org/edition-guide版本差异
Cargo Bookdoc.rust-lang.org/cargo构建工具
rustdoc Bookdoc.rust-lang.org/rustdoc文档生成
Referencedoc.rust-lang.org/reference语言规范
RFC Bookrust-lang.github.io/rfcs特性设计原因

三、视频课程

课程平台内容推荐程度
★ Crust of RustYouTube (Jon Gjengset)深入单个特性必看
Let’s Get RustyYouTube入门系列好
Jon Gjengset 的直播录像YouTube实际项目编码专家级
Tensor ProgrammingYouTube项目实战好
中文: Rust 编程语言入门Bilibili中文入门好

四、博客与文章

英文资源

来源链接特点
★ fasterthanlimefasterthanli.me深度技术文章
★ Niko Matsakis 博客babysteps.computer借用检查器/NLL 作者
Mara Bosblog.m-ou.se并发专家
This Week in Rustthis-week-in-rust.org每周动态
The Overflow (Stack Overflow)Rust 高质量内容
Tokio Blogtokio.rs/blog异步权威

中文资源

来源特点
Rust语言圣经 (RustCN)course.rs - 中文最好的 Rust 教程
Rust中文社区rustcc.cn
张汉东的Rust实战课极客时间 - 付费但质量高

五、开源项目推荐

适合学习代码的项目

项目Stars学习点
★ ripgrep47k+高质量命令行工具, 并行, 正则
★ tokio27k+异步运行时内部实现
axum19k+类型驱动的 Web 框架
serde9k+过程宏的极致应用
crossbeam7k+并发数据结构
rayon11k+数据并行的优雅实现
nom9k+Parser combinator
clap14k+CLI 解析, derive 宏的好例子

有趣的 Rust 项目

项目描述
alacrittyGPU 加速终端
zed高性能代码编辑器
helixVim-like 编辑器
rustdesk远程桌面
polars高性能 DataFrame
denoJS/TS 运行时

六、工具链

必备工具

# 安装 Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
 
# 常用命令
rustup update          # 更新工具链
rustup component add clippy rustfmt rust-analyzer
 
cargo new my_project   # 创建项目
cargo build --release  # 构建
cargo test             # 测试
cargo clippy           # Lint
cargo fmt              # 格式化
cargo doc --open       # 生成文档
cargo bench            # 基准测试

推荐 cargo 扩展

工具安装用途
★ cargo-watchcargo install cargo-watch文件变化自动重编译
cargo-expandcargo install cargo-expand宏展开查看
cargo-asmcargo install cargo-asm查看生成汇编
cargo-auditcargo install cargo-audit安全漏洞审计
cargo-outdatedcargo install cargo-outdated检查依赖更新
cargo-llvm-linescargo install cargo-llvm-lines分析编译时间
cargo-criterioncargo install cargo-criterion基准测试
flamegraphcargo install flamegraph性能火焰图
cargo-udepscargo install cargo-udeps找无用依赖

IDE 配置

# VS Code (推荐)
扩展: rust-analyzer (必装)
扩展: Even Better TOML
扩展: CodeLLDB (调试)
扩展: crates (Cargo.toml 依赖提示)

# 设置 (settings.json)
{
    "rust-analyzer.checkOnSave.command": "clippy",
    "rust-analyzer.inlayHints.enable": true,
    "editor.formatOnSave": true
}

七、社区与问答

平台链接特点
★ Rust Users Forumusers.rust-lang.org官方问答社区
Rust Internalsinternals.rust-lang.org语言设计讨论
r/rustReddit社区新闻
Rust Discorddiscord.gg/rust-lang实时问答
Stack Overflowtag: rust技术问答
知乎 Rust 话题中文讨论

八、速查表 (Cheat Sheet)

所有权速查

值绑定: let x = value;       → x 拥有 value
移动:   let y = x;           → y 拥有, x 不可用 (非Copy)
复制:   let y = x;           → y 是副本, x 仍可用 (Copy类型)
借用:   let r = &x;          → r 借用 x, x 仍可用
可变借:  let r = &mut x;      → r 可变借用 x (独占)
克隆:   let y = x.clone();   → 深复制, 两者独立

生命周期速查

// 函数
fn foo<'a>(x: &'a str, y: &'a str) -> &'a str { ... }
 
// 结构体
struct Foo<'a> {
    x: &'a str,
}
 
// 方法
impl<'a> Foo<'a> {
    fn method(&'a self) -> &'a str { ... }
}
 
// 'static
fn static_ref() -> &'static str { "hello" }  // 字符串字面量

错误处理速查

// 返回类型
fn foo() -> Result<T, E>
fn bar() -> Option<T>
 
// 传播错误
let x = foo()?;  // 失败时提前返回
 
// 转换
result.unwrap()           // panic on err
result.expect("msg")      // panic with msg
result.unwrap_or(default) // 默认值
result.map(|v| ...)       // 转换 Ok 值
result.and_then(|v| ...)  // 链式 Result

Trait 速查

// 定义
trait Greet {
    fn greet(&self) -> String;
    fn hello(&self) { println!("{}", self.greet()); }  // 默认实现
}
 
// 泛型约束
fn print<T: Display + Debug>(val: T) { ... }
fn print<T>(val: T) where T: Display + Debug { ... }
 
// Trait 对象
fn do_stuff(val: &dyn Trait) { ... }      // 借用
fn do_stuff(val: Box<dyn Trait>) { ... }  // 拥有

九、学习计划建议

最快路径 (8 周)

Week 1-2: TRPL 第1-10章 + Rustlings 前半
Week 3-4: 本教程 01-04 章 + 实战项目1 (minigrep)
Week 5-6: 本教程 05-07 章 + 实战项目2 (下载器)  
Week 7-8: 本教程 08-10 章 + 面试准备

深度路径 (12 周)

Week 1-3:  TRPL 全书 + Rustlings + cargo 工具熟悉
Week 4-6:  Programming Rust + 本教程 01-05 章
Week 7-9:  本教程 06-10 章 + Rust for Rustaceans
Week 10-12: 实战项目3-4 + 开源贡献准备

十、常见依赖 Crate 推荐

[dependencies]
# 序列化/反序列化
serde = { version = "1", features = ["derive"] }
serde_json = "1"
 
# 错误处理
thiserror = "1"  # 库使用
anyhow = "1"     # 应用程序使用
 
# 异步
tokio = { version = "1", features = ["full"] }
 
# HTTP 客户端
reqwest = { version = "0.11", features = ["json"] }
 
# CLI
clap = { version = "4", features = ["derive"] }
 
# 日志
tracing = "0.1"
tracing-subscriber = "0.3"
 
# 时间
chrono = "0.4"
 
# 随机数
rand = "0.8"
 
# 并行
rayon = "1"
 
# 正则
regex = "1"
 
# UUID
uuid = { version = "1", features = ["v4"] }
 
[dev-dependencies]
# 测试
criterion = { version = "0.5", features = ["html_reports"] }  # 基准测试
proptest = "1"  # 属性测试

🦀 持续学习, 不断进步! Rust 社区欢迎你!