Files
docs-rust/ch06/ch06-00-enums.html
2026-06-22 21:27:36 +05:30

20 lines
956 B
HTML
Raw Permalink 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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Enums and Pattern Matching</title>
</head>
<body>
<h1 id="enums-and-pattern-matching"><a class="header" href="#enums-and-pattern-matching">Enums and Pattern Matching</a></h1>
<p>In this chapter, well look at enumerations, also referred to as <em>enums</em>.
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 <code>Option</code>, which
expresses that a value can be either something or nothing. Then, well look at
how pattern matching in the <code>match</code> expression makes it easy to run different
code for different values of an enum. Finally, well cover how the <code>if let</code>
construct is another convenient and concise idiom available to handle enums in
your code.</p>
</body>
</html>