Rust Tutorial #7: Enums and Pattern Matching
In the previous tutorial, we learned structs — types where every value has the same fields. But sometimes a value can be one of several different kinds. That is what enums are for. Enums in Rust are much more powerful than in most languages. In Java or Kotlin, enums are just named constants. In Rust, each variant can hold different data. Combined with pattern matching, enums become one of Rust’s best features. ...