gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 07:42:41 28 4
gpt4 key购买 nike

我很好奇这段历史。我认为 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com