Like structures, enumerations allow us to establish a new data type. The content is different from a structure, though. When we say that the data type of a variable is an enumeration, we're telling Rust that its contained value is required to be one of the specific choices we've described for that enumeration and can't be anything else.
Enumerations
Basic enumerations
In Rust, an enumeration is a data type representing one of a fixed set of values. For example, we could define an enumeration of the commonly recognized seven colors of the rainbow, as shown here:
pub enum Color {
Red,
Orange,
Yellow,
Green,
Blue,
Indigo,
Violet,
}
Once we define this enumeration, we can use Color as a data...