2024-06-15 23:48:04 +08:00

11 lines
583 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 枚舉
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)