10.8 Enums in Collections and Functions
Even if the variants store different amounts of data, the compiler treats the enum as a single type.
10.8.1 Storing Enums in Collections
let messages = vec![
    Message::Quit,
    Message::Move { x: 10, y: 20 },
    Message::Write(String::from("Hello")),
];
for msg in messages {
    msg.call();
}
- Homogeneous Collection: All elements share the same enum type.
 - No Boxing Needed: If the variants fit in a reasonable amount of space, there’s no need to introduce additional indirection with a smart pointer.
 
10.8.2 Passing Enums to Functions
You can pass enums to functions just like any other type:
fn handle_message(msg: Message) {
    msg.call();
}
fn main() {
    let msg = Message::ChangeColor(255, 0, 0);
    handle_message(msg);
}