© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
C. MilanesiBeginning Rusthttps://doi.org/10.1007/978-1-4842-7208-4_7

7. Enumerations and Matching

Carlo Milanesi1  
(1)
Bergamo, Italy
 
In this chapter, you will learn:
  • How enums help in defining variables that can take on values only from a finite set of cases

  • How enums can be used to implement discriminated union types

  • How to use the match pattern-matching construct to handle enums

  • How to use the match construct to handle other data types, like integer numbers, strings, and single characters

  • How to define enumerations containing fields of data and how to match them with literals

  • How to define variables in patterns of match statements

  • How to use match expressions ...

Get Beginning Rust: Get Started with Rust 2021 Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.