:::info 更新:建议与经验 > 1. 学 Rust 的误区 ::: 说实话,Rust 的学习资源真的不少。。。所有内容搜集自本人学习 Rust 过程,只依照个人兴趣添加。
合辑
- ❤❤ 官方教程(入门到进阶、最基础而全面):https://www.rust-lang.org/zh-CN/learn
★ the book: 英文原版 | (伪)官方中文版 | KaiserY 中文翻译版 | learnku 中文翻译版
官方资讯动态
公告:https://blog.rust-lang.org/ (对外) | https://blog.rust-lang.org/inside-rust (对内)周报:[_https://this-week-in-rust.org/](https://this-week-in-rust.org/)论坛:[_https://users.rust-lang.org/](https://users.rust-lang.org/)_ (对新手)| [_https://internals.rust-lang.org/](https://internals.rust-lang.org/)_ (对老手)
社区:[_https://www.rust-lang.org/community](https://www.rust-lang.org/community) - ❤❤ Rust 官方教程翻译(中文资料里入门必看,官方教程最基础的部分):https://rustwiki.org/docs/
Rust 中文资源网(FAQ):https://rustwiki.org/ | Rust 中文翻译项目组:https://github.com/rust-lang-cn**Rust 最大中文社区论坛:https://rustcc.cn/ | 《Rust 社区运营3周年总结》**Rust 最大中文社区索引站:https://rustcc.com/**小众中文社区的翻译资料/论坛:https://learnku.com/rust - 7k★非常全面而细致的学习资料合辑:https://github.com/ctjhoa/rust-learning
- 简明而经典的学习资料合辑:https://github.com/mre/idiomatic-rust
- 2021 年去哪学 Rust:https://loige.co/where-to-go-to-learn-rust-in-2021/
- Rust Cheat Sheet(语法小结):https://cheats.rs/
- Rust 中文书架与资讯:https://budshome.com/ | https://blog.budshome.com/
- 简要而基础的 Rust 知识(适合在 Rust Book 阶段当作补充材料):https://learning-rust.github.io/
- ❤ Rust 语言开源杂志(2021,张汉东统稿):
github.io: https://rustmagazine.github.io/rust_magazine_2021/
github repo:https://github.com/RustMagazine/rust_magazine_2021
语雀:https://www.yuque.com/chaosbot/rust_magazine_2021 - 微软发布的 Rust 新手教程:https://docs.microsoft.com/en-us/learn/paths/rust-first-steps/
- Leetcode | AoC 刷题:
https://rustgym.com/
https://github.com/SmiteWindows/leetcode/
https://stevenbai.top/rust-leetcode/2020-07-09/
https://github.com/BurntSushi/advent-of-code - 30 本 Rust 编程书籍推荐【仅记录】:https://www.nowcoder.com/discuss/749001
p.s. 建议从官方和其他公开资料学习 Rust,有些久远的书籍不必再看,此外书籍的质量并不一定比网络资料强。 - How to learn modern Rust(资料合辑):https://github.com/joaocarvalhoopen/How_to_learn_modern_Rust
- 数据结构 + Rust 书:https://rustcc.cn/article?id=cff25d75-720e-4b33-a33f-c487ce78d00f
- Rust for the Polyglot Programmer:https://www.chiark.greenend.org.uk/~ianmdlvl/rust-polyglot/
- The Little Book of Rust Books:https://lborb.github.io/book/
A Computer Science Curriculum with Rust flavor:https://github.com/AbdesamedBendjeddou/Rusty-CS
实战
❤ Rust by Example 通过例子学 Rust:https://doc.rust-lang.org/rust-by-example/index.html
- Rust by Example (Extended) 通过例子学 Rust (非官方拓展版):https://rust-by-example-ext.com
- ❤ Rust Cookbook 实战小案例:https://rust-lang-nursery.github.io/rust-cookbook/intro.html
中文版:https://rust-cookbook.budshome.com/ - (官方)帮助编写地道 Rust 程序的小练习:https://github.com/rust-lang/rustlings/ | via 苦瓜小仔 | via yunwei
- quiz:https://github.com/dtolnay/rust-quiz
- ❤ 与 Rustc 开发者一起阅读源码 (RRC):https://github.com/rust-lang/rustc-reading-club
- 从 2021 年 11 月开始,每月第 1 和 3 个周四举行在线会议,具体时间安排见 google calendar。
- 活动目的就是为了让更多人为 Rust 编译器做贡献。不会有任何回放,只能实时参与。
- Niko 和 Jones 为主要组织者,入会必看:notes from Niko、faq。
- 为了响应官方的活动,张汉东老师在飞书的 Rust 中文社群也准备每周六或日,也组织一次源码阅读在线沙龙。
exercism:is an independent, community funded, not-for-profit organisation.
进阶
去 Rust 官方仓库看看吧:https://github.com/rust-lang
- Reference(参考手册,Rust Book 的简要&全面版):https://doc.rust-lang.org/stable/reference/
中文版:via minstrel1977 | via rustwiki - The Dark Arts of Unsafe Rust (Nomicon):https://doc.rust-lang.org/stable/nomicon/index.html
中文版(Rust 黑魔法书/死灵书):by Summer | by purewhite (新) - Unsafe Code Guidelines Reference(简称 UCG):https://github.com/rust-lang/unsafe-code-guidelines
- UCG 的目标是“推荐” unsafe 代码可以/不要做哪些事,保证 unsafe 代码可依赖,且被认为是 unsafe code reference (应该是简要、完整、正式的文档);
- 而 Reference 一书是从 RFC (即 Rust 语言规范)整理来的(主要是 Rust 的 safe 部分);
- Nomicon 一书是讨论 unsafe 的草案,介绍如何编写 unsafe 代码以及很多细节描述,其目的是在写入 UCG 之前达成一致意见;另一方面 Nomicon 是 Reference 的高级篇。
- 以上三点描述主要从 UCG 的 README 和 Nomicon 的 Introduction 整理而来,括号内的部分是笔者自己的理解。
- Rust API Guidelines:https://rust-lang.github.io/api-guidelines/
中文版(Rust API 编写指南):https://github.com/zjp-CN/api-guidelines - Edition Guide(2015 / 2018 / 2021):https://doc.rust-lang.org/stable/edition-guide/
- Rustc (Rust 编译器相关)
- 使用指南:Rustc Book
- 开发指南:Rustc Dev Guide | 中文版(翻译招募中)
- RFC(Rust 新特性预案/设计稿):https://github.com/rust-lang/rfcs
- (官方)补充文档合辑:https://forge.rust-lang.org/
- 给标准库开发者/贡献者的书:https://std-dev-guide.rust-lang.org/
- Reference(参考手册,Rust Book 的简要&全面版):https://doc.rust-lang.org/stable/reference/
- Rust-Unofficial:https://github.com/rust-unofficial_Catch-all organization for unofficial Rust projects which have become orphaned or otherwise need community maintainership
- 20k★awesome Rust (Rust 最棒的应用合辑整理):https://github.com/rust-unofficial/awesome-rust
- Rust 编程的风格和模式:https://github.com/rust-unofficial/patterns
中文版:https://github.com/chuxiuhong/chuxiuhong-rust-patterns-zh (新)| https://plus7wist.gitee.io/rust-patterns-zh/ (旧) - 通过 linked list 学习 Rust:https://rust-unofficial.github.io/too-many-lists/
中文版:https://learnku.com/articles/58291
- Webassembly:https://github.com/rustwasm | https://rustwasm.github.io/
Webassembly Book:https://rustwasm.github.io/docs/book/
Wasm-Bindgen Book:https://rustwasm.github.io/docs/wasm-bindgen/
Wasm-Pack Book:https://rustwasm.github.io/docs/wasm-pack/
Mozila Wasm: Rust to Wasm | JS-Wasm
A curated list of awesome things related to Yew / WebAssembly:https://github.com/jetli/awesome-yew
A Workshop for Learning Rust and WebAssembly:https://github.com/rylev/rust-wasm-workshop - 宏编程:
- 声明宏:
- The Little Book of Rust Macros (updated):英文版 (by veykril) | 中文版 (by zjp-cn)
- 过程宏:
- Reference: procedural-macros
- syn/examples:过程宏入门案例
- 文档:quote | syn
- dtolnay:proc-macro-workshop
- https://github.com/dtolnay/case-studies
- https://blog.turbo.fish/
- https://zjp-cn.github.io/rust-note/proc-macro-note.html:(中文)过程宏相关库的梳理
- (仅记录)rustc 1.31~1.45 版本中的过程宏:https://github.com/dtolnay/proc-macro-hack
- 文章:
- 声明宏:
- Rust in Blockchain:
https://github.com/rust-in-blockchain
https://github.com/rust-in-blockchain/awesome-blockchain-rust - 性能提升指南:
- 【Rust 官方】rustc-perf (primary benchmark suite used for gauging Rust compilation speed, in particular for detecting improvements and regressions):
https://perf.rust-lang.org/ 、https://perf.rust-lang.org/compare.html - The Rust Performance Book:https://nnethercote.github.io/perf-book/
- Rust SIMD Performance Guide:https://rust-lang.github.io/packed_simd/perf-guide/introduction.html
- Effective Rust Book:https://www.lurklurk.org/effective-rust
- High Assurance Rust: Developing Secure and Robust Software:https://highassurance.rs/
- 文章:
- 【Rust 官方】rustc-perf (primary benchmark suite used for gauging Rust compilation speed, in particular for detecting improvements and regressions):
- Rust 代码规范合辑【由张汉东组织,可贡献】:https://github.com/Rust-Coding-Guidelines/rust-coding-guidelines-zh
- Android Rust(官方):https://source.android.com/setup/build/rust/building-rust-modules/overview
异步:
- wg-async-foundations(Rust 官方异步设计工作小组):https://rust-lang.github.io/wg-async-foundations
- 【Rust 官方】async fundamentals initiative:https://rust-lang.github.io/async-fundamentals-initiative/
- Are we async yet? https://areweasyncyet.rs/(Yes! The long-awaited async/await syntax has been stabilized in Rust 1.39.)
- 书籍:
- Rust 官方:async book | 中文版 (by huangjj27)
- async-std 官方教程:英文版 | 中文版
- tokio 官方教程:英文版 | 旧中文版 ( 2019 停止更新 ) | 新中文版 (by SinSay Chen)
- no-std (bare metal) async:Demystifying Async/Await in Rust (by André Borrmann)
- 博客:
- tokio 官方博客:https://tokio.rs/blog
- async-std 官方博客:https://async.rs/blog/
- cfsamson:https://github.com/cfsamson
- Stjepan Glavina 许多异步库的作者:博客存档 | 一些背景 | 背景2 | 以下是博文翻译版本
- stevenbai.top (github: nkbai)
- 赖智超:知乎专栏 - Rust 异步与并发
- Alex Chi (io_uring 相关):https://www.skyzh.dev/posts
- Alice Ryhl(tokio 相关):https://ryhl.io/blog/
- carllerche(tokio 相关):https://carllerche.netlify.app/
- Guillaume Endignoux:https://gendignoux.com/blog/
- Understanding Rust futures by going way too deep
- Futures Concurrency 系列:https://blog.yoshuawuyts.com/
- Rust 异步早期博客:
- https://itsallaboutthebit.com/
- 视频:Jon Gjengset
- 文章:
- Futures and Segmented Stacks (by without-boats)
- Pin
- 【基础概念】进程、线程、进程池、进程三态、同步、异步、并发、并行、串行
- Writing an OS in Rust: Async/Await
- Let’s talk about this async
- A Guided Tour of Streams in Rust
- Move Constructors in Rust: Is it possible? (by mcyoung 2021.04)
- A short introduction to async Rust (2022.06)
- Into the Future with IntoFuture - Improving Rust Async Ergonomics (2022.06)
视频
Crust of Rust(Jon Gjengset 讲述 Rust 的编程思想和技巧):https://www.youtube.com/channel/UC_iD0xppBwwsrM9DegC5cQQ
- Niko 的 YTB 频道(关于 rustc、async、rayon):https://www.youtube.com/user/nikomatsakis/playlists
- Aleksey Kladov(rust-analyzer 作者亲自详解 analyzer):https://www.youtube.com/playlist?list=PLhb66M_x9UmrqXhQuIpWC5VgTdrGxMx3y
- Easy Rust (Easy Rust - learn to program in Rust with simple English)的作者用简单的英语词汇录制了一系列 Rust 教程的视频,发布在了 YouTube。每集 5 到 10 分钟,总共 186 集,23 个小时。https://www.youtube.com/playlist?list=PLfllocyHVgsRwLkTAhG0E-2QxCf-ozBkk
- Learn Rust with Gitoxide(gitoxide is an idiomatic, lean, fast & safe pure Rust implementation of Git):https://www.youtube.com/playlist?list=PLMHbQxe1e9Mk5kOHrm9v20-umkE2ck_gE
- 令狐壹冲(2020年至今仍在更新视频,从入门到进阶、区块链+Rust):
(B 站)https://space.bilibili.com/485433391/video
(博客)https://learnku.com/blog/linghuyichong - reddit: Creating a 2 hour Rust intro for my university’s intro systems class:其评论列出了一些视频资源
- https://github.com/jack1232/wgpu-Step-By-Step:wgpu Graphics Programming in Rust: Step-by-Step(国人)
- Ryan Levick(中级):https://www.youtube.com/c/RyanLevicksVideos
- Bevy 教程:
- 【内存布局】Visualizing memory layout of Rust’s data types:https://www.youtube.com/watch?v=rDoqT-a6UFg
库资源
以下渠道可以全面搜索最新的各个领域的最热门 lib crate:
- 【库发布平台】crates.io 👈
The Rust community’s crate registry.
官方维护的 lib / binary 发布平台。你的 Rust 项目所拉取的三方库默认都是从 crates.io 上下载的。cargo install 的 binary 也是从上面下载源码的。
上面有下载量排名、领域分类、crate 信息 | 版本历史 | dependancies | depenents (后两个按下载量排序)。 - 【库整合(划分领域)】lib.rs 👈
Rust libraries and applications. Fast, lightweight, opinionated, unofficial alternative to crates.io.
主要把 crates.io 的 libs 分门别类。前者的分类依据是作者在 Cargo.toml 所填的类别,后者结合使用场景。
当然也会包括只在 github 的一些 crates。此外还提供更简明的数据统计。 - 【应用合辑(划分领域)】awesome-rust 👈
A curated list of Rust code and resources.
与 lib.rs 一样,把 libs 分门别类。但是主要搜集 github repos 链接,不提供数据统计。某些 lib 有可能不会发布到 crates.io 上。 - 【库文档平台】docs.rs 👈
_An open source documentation host for crates of the Rust. All libraries published to crates.io are documented.与 crates.io 紧密联系的 lib 文档发布平台。内容来自于 crate 作者写的文档注释,由 Rustdoc 自动生成。 - 【文档搜索插件】https://github.com/huhu/rust-search-extension
The ultimate search extension for Rust.
在 docs.rs 上搜索公有 API 文档。默认搜索标准库相关的 crate API,也可手动添加 crate 搜索列表。 - 【流行榜单】
See what the GitHub community is most excited about today:https://github.com/trending/rust
hunt rust trending:https://www.libhunt.com/l/rust/trending - 【拓展 std】stdx | Rust Cookbook | stdx-dev
stdx: The missing batteries of Rust
_Rust 生态最基础而重要的库合辑,其中很多库的作者就是编写标准库的作者,所以这些库拓展了标准库。(这曾是官方成员 brson 制定的重要任务,目前这个合辑已停止更新)__cookbook: a collection of simple Rust examples that demonstrate good practices to accomplish common programming tasks
而 Rust Cookbook 继承了 stdx 库合辑的理念并且提供入门教程,是 stdx 的延续。中文版。
stdx-dev: the missing development batteries of Rust
站在开发人员角度的 stdx ~ 可惜已停止更新 - 【主流编程语言库查询平台】https://libraries.io/
可以根据关键字/分类搜索多个语言的库 - 【Can I use … ?】https://caniuse.rs/
查询每个 Rust 发行版本的 API 稳定情况。 - 【Sourcegraph】https://about.sourcegraph.com/
基于87k+ Rust crates 源代码进行高级搜索,使用 demo
- GUI:https://lib.rs/search?q=gui
- 线性代数、数学物理:https://rustsim.org/
- 异步:https://lib.rs/asynchronous
- Web 开发者技能树:https://github.com/anshulrgoyal/rust-web-developer-roadmap
- OS 月报:https://rust-osdev.com/
- Awesome Embedded Rust:https://github.com/rust-embedded/awesome-embedded-rust
- too many to list
Rust 社区非常关注的几个领域 (Are we … yet?):
- 游戏:https://arewegameyet.rs/(Almost. We have the blocks, bring your own glue.)
- GUI: https://areweguiyet.com/ (The roots aren’t deep but the seeds are planted.)
- Web:https://arewewebyet.org/(Yes! And it’s freaking fast!)
- 异步:https://areweasyncyet.rs/(Yes! The long-awaited async/await syntax has been stabilized in Rust 1.39.)
- IDE: https://areweideyet.com/(更新滞后)Last updated: 2019 and even earlier
- 机器学习/科学计算:https://www.arewelearningyet.com/ (It’s ripe for experimentation, but the ecosystem isn’t very complete yet. )Last updated: 2020-11-23
- 相关讨论:Is rust good for mathematical computing? | How can one make Rust excel in the Sciences?
功能替代
在某些特殊的情况下可能考虑的 std 功能替代品。
- 相关讨论:Is rust good for mathematical computing? | How can one make Rust excel in the Sciences?
std | crate doc | reason |
---|---|---|
alloc crate | coca | operate on a given block of memory, and never reallocate |
heapless | static friendly data structures that don’t require dynamic memory allocation | |
Vec | tinyvec | 基于数组的定长 Vec 类型,存放于 stack;统一 stack / heap 两种 Vec 型的枚举体 |
String | smartstring | for reducing your heap allocations and increasing the locality of string data |
compact_str | a string type that stores short strings (strings <= 24 bytes) on the stack, and transparently stores longer strings on the heap | |
Vec / String | arrayvec | 基于数组的定长 Vec / String 类型,存放于 stack |
heapless | static friendly data structures that don’t require dynamic memory allocation | |
UTF8 String | encoding_rs | 除 UTF8 之外的字符编码(比如 GBK);起源于/用于 firefox Gecko |
array | generic-array | 元素和长度被定义成泛型的数组 [T; N] 。标准库的数组只支持 [T; n] (即元素可以是泛型 T,但长度必须是非负的编译时已知的常量 n)。 |
hybrid-array | combining const generics with the expressiveness of typenum-based constraints | |
Hasher | aHash | 专门用于内存中的哈希映射,抗 DoS,是 Rust 领域最快的,但不如 SipHash 安全,是 std 目前采用的 Hasher。SipHash 为 Rust 1.36 之前 std 使用的 Hasher。 |
hash related | hashes | Collection of cryptographic hash functions written in pure Rust. |
Map / Set | hashbrown | SwissTable 的 Rust 版本,是 std 目前采用的 Map / Set,默认使用 aHash Hasher。 |
phf | 编译时产生的 Hash Map / Set,可作为 static,速度与 std 的 Map / Set 相当 | |
fnv | 适用于小型输入(这是重点/缺点)、无 DoS 攻击情况;起源于/用于 Rust 编译器项目;其他 Hasher crate:fxhash、seahash;参考此表后的 benchmark 链接。 | |
indexmap | 根据插入/删除或自定义顺序的有序 Map / Set,从而可以按顺序遍历、按位置索引。 | |
dashmap | A direct replacement for RwLock<HashMap<K, V> .Blazing fast concurrent HashMap for Rust. |
|
static | lazy_static | 用来声明运行时初始化的全局 static,比如初始化全局 Vec、HashMap。 |
once_cell / std::lazy |
准 std:惰性求值、一次初始化的 static; 比 lazy_static 更灵活、更方便,应该优先考虑使用。 |
|
Option/Result | either | 通用的泛型二元枚举,用来描述/统一两类情况 |
RefCell/RwLock -> qcell | Statically-checked alternatives to RefCell and RwLock | |
iterator | itertools | Extra iterator adaptors, functions and macros. |
dpc-pariter | Parallel iterator processing library for Rust. | |
lending-iterator | Iterator<Item = &mut T> 、重叠的 slice.windows_mut() |
|
lock | parking_lot | provides implementations of Mutex , RwLock , Condvar and Once that are smaller, faster and more flexible than those in the Rust standard library |
time related | chrono | 功能完备的日期与时间库,涉及 UTC/本地时间/时区 等,几乎是处理时间的首选库。 缺点:在并发情况下可能发生数据竞争,见 此文章;处于维护状态。 |
time | 正在开发中的日期与时间库;保证在最近 6 个月的编译器上编译。 缺点:在并发情况下也可能发生数据竞争,但维护更积极,更推荐它 |
|
str::find / iter::position | memchr | 针对任意编码的字符串位置搜索或者任意字节位置搜索的深度优化库:比标准库的效率更高;在更多平台上获得加速。 |
iterator:: count |
bytecount | 快速计算给定字节的出现次数或 UTF-8 代码点的数量。特点:利用现代 CPU 的特性来显著加快计数;可以对含有非 UTF8 字符的切片计算 UTF8 字符数量 。 |
u128 / i128 | ibig | A big integer library with good performance. |
mem::replace | take_mut | take_mut 基于 &mut 和 unsafe ,可以在闭包内部直接消耗第一个参数的所有权。 |
std::process::Command | duct | run child processes with support for pipelines and IO redirection |
subprocess | 低级别的 Popen API(类似于 py 的 subprocess.Popen); 高级别的创建命令、管道 API;支持灵活的重定向;非阻塞和超时方法进行等待。 |
|
xshell | easy to write cross-platform “bash” scripts in Rust (可以考虑在 build.rs 文件中使用) | |
concat! -> const_concat! | heinous hackery to concatenate constant strings | |
include_str! -> include_dir! | embedding an entire directory tree into your binary | |
{:#?} |
tabled | For pretty print tables of Rust structs and enums |
custom-format | 自定义 format specifiers,比如"{prefix}: {0 :%Y}-{0 :%m}-{0 :%d} {0 :%H}:{0 :%M}:{0 :%S}.{0 :%9N}" |
|
Rc / Arc | hybrid-rc | Thread-safe hybrid reference counting pointers |
Any | castaway | ergonomic compile-time downcasting rather than runtime downcasting |
Rust 具有优秀的单元/集成测试功能,但是某些特定场景下,其他形式的测试或者测试工具或许很有用。 | ||
可以直接替换掉 #[test] 的属性宏 |
test-case | 非常适合于批量测试函数的值(或者原测试函数重度依赖 assert_eq! ,需要把每条断言拆分成单独的测试函数)。 |
parameterized | 与 test-case 类似,但特点在于,你可以把多个测试用例放到一个属性里 | |
rstest | Fixture-based test framework for Rust | |
#[test] related | insta | 快照测试 (snapshots/approval tests) 适用于以下一种或多种测试情况: 1. 被测试对象很大:比如很长的字符串、很复杂的结构体、又长又复杂的 Vec; 1. 运行的结果不确定或者经常变动:比如基于随机数的结果、网络请求的结果; 1. 对测试结果的变化很敏感:比如比对与上一次测试结果的差异; 1. 接受测试结果后,自动填充测试结果,或者把测试结果写入到统一的文件。 |
insta-cmd | 把 insta 的快照测试模式用于测试命令行工具(stderr/stdout) | |
#[test] related | trybuild | 针对编译器诊断信息的 UI 测试 (ui tests of compiler diagnostics),它适用于: 1. 测试结果很重要,而且测试过程中的 stdout/stderr 信息也很重要; 1. 非常关注失败的测试,尤其是编译时失败的测试 (compile-fail tests) 的诊断信息; 1. 汇集多个二进制测试文件到一组测试。 |
#[test] related | quickcheck | todo Alternatives for fuzzing: Rust Fuzz Book and the arbitrary crate. |
assert_*! -> static_assertions | 于编译时 在 size、impl、trait、type 等方面作出断言。 | |
matches! -> assert_matches | matches! 的 assert! 版本:对模式断言。 |
|
assert_eq! -> assert_unordered | For types that implement IntoIterator and therefore can show only the differences | |
cargo-mutants | mutation testing for Rust | |
cargo test -> cargo nextest | 更简明美观的测试结果展示;把测试放到到单独的进程中并行运行,从而得到具体的测试时间、加快整体测试速度。 | |
benchmark tool (Rust lib) | ||
criterion | A statistics-driven micro-benchmarking library written in Rust. | |
iai | Experimental One-shot Benchmark Framework in Rust (based on Valgrind) | |
dhat | provides heap profiling and ad hoc profiling capabilities to Rust programs, similar to those provided by Valgrind’s DHAT | |
模式拓展 | ||
构造函数:derive-new | 使用过程宏快速给结构体和枚举体生成 new 方法 |
|
builder 模式 | typed-builder | 使用过程宏给你的类型生成 builder pattern |
makeit | Compile-time checked Builder pattern derive macro with zero-memory overhead | |
buildstructor | derive builders rather than structs | |
superstruct | Rust library for versioned data types | |
owning_ref | ouroboros | self-referential | |
rust-std-candidates | Candidates for addition to stdlib: each crate is published separately | |
delegate | removes some boilerplate for structs that simply delegate some of their methods to one or more of their fields (against Deref polymorphism antipattern) | |
动态分发 -> 静态分发:enum_dispatch | transforms your trait objects into concrete compound types, increasing their method call speed up to 10x | |
声明宏辅助 | darling | a crate for proc macro authors, which enables parsing attributes into structs |
基准测试
- (2020) A Guide to Contiguous Data in Rust
- 一些 Map / Set benchmarks:
- String concatenations benchmarks (updated):https://github.com/rimutaka/concatenation_benchmarks-rs/tree/macros
- Rust String Parsing Benchmarks:https://github.com/epage/string-benchmarks-rs
- Rust Arg Parsing Benchmarks:https://github.com/rust-cli/argparse-benchmarks-rs
- Rust serialization: What’s ready for production today?(2020):https://blog.logrocket.com/rust-serialization-whats-ready-for-production-today/
- Benchmarking different Rust generator libraries in a real world use case.:https://github.com/Tuupertunut/rust-generator-benchmark
- Rust JSON (Parsing) Benchmark:https://github.com/serde-rs/json-benchmark
- Rust Markdown Parsing Benchmarks:https://github.com/epage/parse-benchmarks-rs
Rust embedded scripting languages benchmark:https://github.com/khvzak/script-bench-rs
个人博客
网址后面是我总结的关键词(不保证准确),所有博客的地址来自于寻找 Rust 资料时顺便搜集的:
❤ Educational blog posts for Rust beginners and advanced beginners:https://github.com/pretzelhammer/rust-blog:最热门的一篇莫过于《理解生命周期的十个误区》
- Dimitri Sabadie- functional programming, graphics, demoscene, optimization :https://phaazon.net/blog
- https://brson.github.io/rust-anthology/1/index.html:brson | Rust 官方成员大佬
- https://docs.rs/dtolnay/0.0.9/dtolnay:dtolnay | Rust 官方成员大佬
- Steve J Donovan:https://stevedonovan.github.io/rust-gentle-intro/ | https://stevedonovan.github.io/rustifications/
- Andre Bogus (曾是音乐家的 Rustacean、clippy 的主要贡献者之一):https://llogiq.github.io/ | https://blog.logrocket.com/author/andrebogus/
- https://medium.com/search?q=rust
- https://adventures.michaelfbryan.com/posts/
- https://blog.polybdenum.com/:Subtype 系列
- https://bheisler.github.io/: Iai (benchmark 相关)
- https://huangjj27.github.io/
- https://rustype.github.io/notes/notes/rust-typestate-series/rust-typestate-index
- https://github.com/Praying/RustBackyard/issues/6
- https://github.com/zsiciarz/24daysofrust:24 天学会 Rust(旧资料了,2017 年停止更新)
- https://jondot.medium.com/
- https://deterministic.space/:Rust 早期
- https://hermanradtke.com/archive.html:Rust 早期
- https://folyd.com/blog:国人 | github | 知乎
- https://www.zhihu.com/column/c_1115180704186613760:国人
- https://without.boats/blog: 异步 | Rust 官方成员
- https://stevenbai.top/:国人 | 区块链 | 异步 | leetcode | 翻译者
- https://github.com/sunnyrust/rustBible:国人 | 书籍 | 《Rust扭转乾坤》
- https://blog.guillaume-gomez.fr/:Guillaume Gomez | Rustdoc team leader
- https://readrust.net/
- EthanYuan 个人搜集的资源:https://github.com/EthanYuan/Rust-Study-Resource
- making a programming language called Eldiro using the Rust programming language:https://arzg.github.io/lang/
- https://theomn.com/
- http://www.wilson-blog.cn/archive.html
- 教程和其他文档的例子合集:https://github.com/eliovir/rust-examples
- 面向中级 Rust 程序员(已经阅读学习完基本教程)的博客:https://www.possiblerust.com/、
- Rust GUI 领域的大佬:https://raphlinus.github.io/
- https://os.phil-opp.com/:Writing an OS in Rust
- https://nnethercote.github.io/:Nicholas Nethercote | Rustc | perf-book
- chinanf-boy(中文译者):http://llever.com/
- https://github.com/rcore-os/rCore-Tutorial-v3:国人 | RISC-V | 操作系统
- https://github.com/0voice/Understanding_in_Rust:Rust 工程师枕边资料
- podcast (播客):
- https://rustacean-station.org/:A community project for creating podcast content for the Rust programming language.
- https://soundcloud.com/arewepodcastyet:A new fn Podcast about all things Rust
https://chercher.tech/rust/:结合 Rust 代码的编程通用设计理念
该博客的理念:learning is FUN - if you do not feel so while learning, then do not learn it
https://rustyyato.github.io/:HKT (GAT related) | Closures
- https://lukaskalbertodt.github.io/:GAT related | and more
- https://smallcultfollowing.com/babysteps/all_posts/:Niko Matsakis | Rust 官方成员(RFC) | Dyn Async Traits Series | and much more
- https://fasterthanli.me/:Amos | 长篇系列博文 | 关于文件读取、ICMP 协议、ELF 文件
- https://github.com/skerkour/kerkour.com:Sylvain Kerkour | 短篇小技巧 | Black Hat Rust 的作者
- https://arzg.github.io/lang/:Luna Razzaghipour | 《使用 Rust 写一个语言》系列
- https://www.rotoclone.zone/blog:《使用 Rust 写一个博客/网站》系列
- https://limpet.net/mbrubeck/:Matt Brubeck | Rust 社区活跃者 | 《使用 Rust 写一个浏览器引擎》系列
- http://plv.mpi-sws.org/rustbelt:RustBelt - Logical Foundations for the Future of Safe Systems Programming 关于 Rust 安全和逻辑方面的学术研究机构
- https://github.com/Ixrec/rust-orphan-rules:Coherence and Orphan Rules in Rust
- https://blog.schichler.dev/
- https://tmandry.gitlab.io/blog/:Tyler Mandry
- https://dev.to/sbelzile:《使用 Rust 写一个游戏》系列
- https://sotrh.github.io/learn-wgpu/:《Learn Wgpu》系列
- https://dpc.pw/:dpc-pariter 作者
- https://github.com/QMHTMY/RustBook:Rust 数据结构和算法书籍(纯中文)
- http://dtrace.org/blogs/
- https://exphp.github.io/blog/ | https://exphp.github.io/unsafe-gotchas:Michael Lamparski (ExpHP) | 高级 Rust 知识系列 | unsafe
- https://blog.yoshuawuyts.com/:异步
- https://github.com/ifsheldon/RustWHY:国人 | Rust 十万个为什么 | Rust 设计模式方面
- https://poignardazur.github.io/:抽象设计
- https://www.sotr.blog/:《Shaking off the Rust》系列 | 围绕具体某个问题的 Rust 实现
- https://michael-f-bryan.github.io/rust-ffi-guide/:The (unofficial) Rust FFI Guide
- https://nullderef.com/:《Plugins in Rust》系列
- https://h2co3.github.io/:H2CO3 | 社区活跃者
- https://www.thecodedmessage.com/:Jimmy Hartzell | Rust vs C++ 系列
- https://www.philippflenker.com/hecto/:《使用 Rust 写一个编辑器》系列
- https://robinmoussu.gitlab.io/blog/:Robin Moussu
- https://blog.jetbrains.com/rust/tag/rust/:Jetbrains 关于 Rust 的博客
- https://gankra.github.io/:《Rustonomicon》|《Learn Rust With Entirely Too Many Linked Lists》作者的博客
- https://jackh726.github.io/:Jack Huey | trait | GAT
- https://aloso.github.io/:tutorial
- https://github.com/tnballo/high-assurance-rust:《High Assurance Rust》书籍
- https://blog.burntsushi.net/:BurntSushi
- https://bfnightly.bracketproductions.com/:《Roguelike Tutorial - In Rust》WASM+游戏
- https://alexgaynor.net/:与 Rust 无直接关系的洞察
- https://lucumr.pocoo.org/:unsafe Rust
- https://aturon.github.io/:Aaron Turon | 早期
- https://github.com/ehsanmok/create-your-own-lang-with-rust:ehsanmok |《Create your own programming language with Rust》
- https://pnkfx.org/:Felix | 早期
- https://patrickfreed.github.io/:patrickfreed | Mongodb
- https://sabrinajewson.org/blog/:GAT related | async drop
- https://github.com/rylev:Ryan Levick | 早期 | 《learn-rust-the-hard-way》|《rust-wasm-workshop》|《rust-workshop》
- https://gatowololo.github.io/blog/main/:Omar S. Navarro Leija | Patching Cargo Dependencies
- https://jamesmunns.com/blog/:James Munns | Postcard crate | 嵌入式
- https://blog.m-ou.se/:Mara Bos | m-ou-se | Rust 官方成员
- https://conradludgate.com/:Conrad Ludgate
- https://davidkoloski.me/blog/:David Koloski | impl trait 语法思考
- https://medium.com/@predrag.gruevski:《Compiler Adventures》系列
- Rust: A Critical Retrospective:硬件背景程序员对 Rust 的反思
- https://blog.nindalf.com/:Krishna
- https://flakm.github.io/:Maciek | Rust interview questions | Profiling heap allocation in rust
- https://vorner.github.io/:Vorner | self-appointed member of the Rust Evangelism Strike Force
- https://hirrolot.github.io/:Hirrolot | 语言洞察
- https://mcyoung.xyz/:Miguel Young | Rust & C++
- https://veykril.github.io/:Lukas Wirth | tlborm 新版的作者 && Rust-Analyzer 的主要维护者
- https://bfnightly.bracketproductions.com/
- https://blog.urth.org/2021/03/14/writing-a-postgres-sql-pretty-printer-in-rust-part-1/:《Writing a Postgres SQL Pretty Printer in Rust》系列
- https://www.ralfj.de/blog/:Ralf Jung | miri 作者 | 官方成员
- https://refaktory.net/blog:Christoph Herzog
- https://medium.com/@carlmkadie:Carl M. Kadie | py & Rust | 数据科学
- https://haibane-tenshi.github.io/:Futuristic Rust | Obscure Rust
- https://dhghomon.github.io/easy_rust:《Easy Rust》| 中文
- http://cliffle.com/:Cliff L. Biffle |《Learn Rust the Dangerous Way》系列
https://laurmaedje.github.io/posts/:Laurenz | https://typst.app/ LaTex 的 Rust 替代品作者
建议与经验
How not to learn Rust (2021.12 via Denys Séguret):《别这样学 Rust》、《学 Rust 的十二个误区》
(原文中肯,英文也简单,没必要翻译了;根据我的理解,罗列出以下重点)- 不要没准备好就想到达一个高水准(因为学 Rust 需要专注的精力和集中的时间)
- 不要不看书就去“钻研”细节(因为你至少需要知道你遇到的细节问题属于哪个范畴)
- 不要基于图的算法来学习 Rust(因为这类算法的数据结构在 Rust 中很难做到,在了解 Rust 之前最好不要尝试)
- 不要不阅读编译器的错误(因为编译器是你遇到问题时的老师,它准确地解释了问题并提出了解决方案)
- 不要忽略编译器的警告(因为这意味着你的代码需要改进)
- 不要应用其他语言所有的最佳实践(因为每个语言都有自己的设计,作者举了很多典型的例子)
- 不要构建生命周期很重的 API(因为你在设计和使用含许多生命周期参数的 API 时会很痛苦,而且传递值的成本并不高)
- 不要忽略非标准库的库(因为非标准库的存在使最好的解决方案出现成为可能)
- 不要使用 unsafe(因为在初步学习 Rust 时你可能不需要 unsafe)、不要滥用 unwrap(因为你可以使用 expect 或 Result 或者选择流行的错误处理库)
- 不要不看文档/源码(因为你阅读精美文档/源码的次数越多,编写精美代码的速度就越快)
- 不要从一开始就设计好一切(因为首先 Rust 使重构变得容易;其次,从可以工作到完整地工作的过程中,你会积累经验;最后,过早和过度优化性能会耗费大量时间)
- 不要在第一个程序中就运用复杂的概念,比如 Rc、dyn、unsafe、Deref (因为它们属于进阶的内容,当你在今后的特定场景中需要它们时,自然会去学习它们、用上它们)
- Rust 性能评估与调优实践 (2021.12 via 张汉东)
-
Rust & Python
Rust 与 Python 交互:https://github.com/rochacbruno/rust-python-example
- RustPython-用 Rust 写 python 编译器:https://github.com/RustPython/RustPython
- Rust for Pythoner:https://rustcc.com/article?id=799121c0-2582-4fef-80c3-9c8f09907121
- Pypolars 一个正在开发的性能超过Pandas的DataFrame库:https://github.com/ritchie46/polars
- python 到 Rust 关于处理错误机制的转换:https://theomn.com/rust-error-handling-for-pythonistas/
- An async python framework with the backend runtime written in Rust: https://github.com/sansyrox/robyn
- Full Stack Rust:https://www.justinm.one/blog/2021/09/11/fullstackrust/ | 中文版
Jupyter Rust:https://jupyter-rust.vercel.app/
Rust vs 其他语言
benchmark 测评文章:这种文章很多了
【Benchmarks Game】Rust versus xx fastest programs:Rust 对比 C/C++/GO
- https://programming-language-benchmarks.vercel.app/rust-vs-cpp
- 小的Rust结构类型,应使用复制还是借用传递?(对比 C++)
- Comparison between Java, Go, and Rust
- Rust FFI vs Golang FFI (cgo)
- https://github.com/GoodManWEN/Programming-Language-Benchmarks-Visualization
- https://github.com/kostya/benchmarks
语言特点比较:
- Rust 与 Haskell 的哲学:https://www.fpcomplete.com/blog/philosophies-rust-haskell/
语法比较
- https://www.programming-idioms.org/
> standard ways of coding standard things, in several popular programming languages - Comparison of Closures in different Languages:https://blog.oberien.de/2022/06/06/finally-getting-closure.html