mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-29 15:19:19 +00:00
11 lines
583 B
Markdown
11 lines
583 B
Markdown
# 枚舉
|
||
|
||
Rust 允許您定義稱為 "枚舉" 的類型,這些類型列舉了可能的值。
|
||
枚舉是許多語言中的一個特性,但其能力在每種語言中都有所不同。Rust 的枚舉最類似於函數式語言中的代數數據類型,例如 F#、OCaml 和 Haskell。
|
||
與枚舉結合使用的有用特性是 Rust 的 "模式匹配" 功能,這使得對枚舉的不同值運行不同代碼變得容易。
|
||
|
||
## 進一步了解
|
||
|
||
- [枚舉](https://doc.rust-lang.org/book/ch06-00-enums.html)
|
||
- [模式語法](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html)
|