mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-26 23:34:17 -05:00
31c25ebb50
After being stuck on exercise enums3.rs for about an hour or two, having read the entire chapter on enums 2-3 times, and still being unable to complete the exercise, i started broadening my reading. I finally found the answer in the rust docs via google.
581 B
581 B
Enums
Rust allows you to define a type called enums
which allow you to enumerate possible values. In combination with enums, we have the concept of pattern matching
in Rust, which makes it easy to run different code for different values of an enumeration. Enums, while available in many languages, Rust's enums are most similar to algebraic data types
in functional languages, such as F#, OCaml, and Haskell.