2 模式匹配

模式匹配 — Comprehensive Rust

译文 · 基于 Comprehensive Rust

原文链接: https://google.github.io/comprehensive-rust/pattern-matching.html

2 模式匹配

本小节约需 50 分钟。内容包括:

内容时长
不可失败模式5 分钟
匹配值10 分钟
解构结构体4 分钟
解构枚举4 分钟
Let 控制流10 分钟
练习:表达式求值15 分钟

2.1 不可失败模式

01-不可失败模式 — Comprehensive Rust

2.2 匹配值

02-匹配值 — Comprehensive Rust

2.3 解构结构体

03-解构结构体 — Comprehensive Rust

2.4 解构枚举

04-解构枚举 — Comprehensive Rust

2.5 Let 控制流

Let 控制流 — Comprehensive Rust

2.6 练习:表达式求值

练习:表达式求值 — Comprehensive Rust

最后修改 August 11, 2026: 更新 (70a5af133)