Skip to content
On this page

Rust 教程

面向已具备编程基础的读者,顺序为工具链与所有权 → 类型与模式 → trait 与错误处理 → 集合与并发 → 测试与 unsafe 边界。示例以 当前 Stable2021 Edition 为默认语境(Cargo.tomledition = "2021")。

章节

章节内容
安装与 Cargorustup、工作区、Cargo.toml/Cargo.lock
所有权、借用与生命周期移动、引用规则、NLL、生命周期省略
类型、切片与字符串标量与复合类型、切片、String/str、UTF-8
结构体、枚举与模式structenummatch、穷尽性
Trait 与泛型trait、dyn Trait、关联类型、where 约束
错误处理Result?thiserror/anyhow 角色
集合与迭代器VecHashMap、迭代器与 collect
并发Send/SyncArcMutex、消息传递
测试cargo test、集成测试目录、#[cfg(test)]
unsafe 与 FFIunsafe 语义、FFI 与 repr 纪律

技术文库