]> git.proxmox.com Git - rustc.git/blob - src/doc/book/src/ch06-00-enums.md
New upstream version 1.67.1+dfsg1
[rustc.git] / src / doc / book / src / ch06-00-enums.md
1 # Enums and Pattern Matching
2
3 In this chapter, we’ll look at *enumerations*, also referred to as *enums*.
4 Enums allow you to define a type by enumerating its possible *variants*. First
5 we’ll define and use an enum to show how an enum can encode meaning along with
6 data. Next, we’ll explore a particularly useful enum, called `Option`, which
7 expresses that a value can be either something or nothing. Then we’ll look at
8 how pattern matching in the `match` expression makes it easy to run different
9 code for different values of an enum. Finally, we’ll cover how the `if let`
10 construct is another convenient and concise idiom available to handle enums in
11 your code.