rust - 为什么 Rust 使用 "match"而不是 "switch"或 "case"?

标签 rust

我很好奇这段历史。我认为 switch 会吸引 C/C++/Java/etc 程序员,因此是一个自然的选择。如果想避免语义上的混淆(因为 matchswitch 更强大),我假设有人会从 Haskell 借用 case

最佳答案

The Rust Reference cites标准 ML (SML) 和 OCaml 对模式匹配有影响。在 OCaml 中,pattern matching uses the match keyword .

The original Rust compiler was written in OCaml ,因此 OCaml 对 Rust 的影响比 Haskell 更大是有道理的。

关于rust - 为什么 Rust 使用 "match"而不是 "switch"或 "case"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40208893/

相关文章:

rust - 二维旋转

rust - 在 Rust 中使用 Rc 时如何防止递归释放导致堆栈溢出?

POST 中的 JSON 正文使用 Rust reqwest Crate

html - 是否有 html5ever 的替代库接受一个字符串并返回一个可查询的对象?

rust - 结构的生命周期边界如何在 Rust 中工作?

rust - 将包含Unicode数字的字符串解析成对应的Unicode字符?

rust - 为什么我不能在线程之间发送 Mutex<*mut c_void>?

rust - : `instance.method::<SomeThing>()` ? 的语法是什么

arrays - 为什么 println!仅适用于长度小于 33 的数组?

json - Rust & Serde JSON 反序列化示例?