blob: 0b9fc7806c8266c6fcb51a281cf5a47be444e304 [file] [log] [blame] [view]
# Enums and Pattern Matching
In this chapter, well look at _enumerations_, also referred to as _enums_.
Enums allow you to define a type by enumerating its possible _variants_. First
well define and use an enum to show how an enum can encode meaning along with
data. Next, well explore a particularly useful enum, called `Option`, which
expresses that a value can be either something or nothing. Then well look at
how pattern matching in the `match` expression makes it easy to run different
code for different values of an enum. Finally, well cover how the `if let`
construct is another convenient and concise idiom available to handle enums in
your code.