知识卡片
首个匹配分支产值
match 先求出待匹配值,再按顺序尝试 pattern => expression。第一个匹配分支决定执行路径,其表达式结果作为整个 match 的值。分支有多条语句时可用花括号,以块的尾表达式提供结果。
相关卡片 [[匹配必须覆盖全域]]
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 枚举与模式匹配 The match Control Flow Construct · 查看原书依据
The code associated with each arm is an expression, and the resultant value of the expression in the matching arm is the value that gets returned for the entire match expression.
参考来源
- 位置:《The Rust Programming Language(第2版)》第06章 枚举与模式匹配(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c06.xhtml`,块 0079)
- 结论依据:原文直接说明命中分支值与整个 match 表达式值的关系。
- 原始内容:The code associated with each arm is an expression, and the resultant value of the expression in the matching arm is the value that gets returned for the entire match expression.