While I was reading The Rust Programming Language, I came across the statement (emphasis mine):
To determine how much space to allocate for a
Message
value, Rust goes through each of the variants to see which variant needs the most space. Rust sees thatMessage::Quit
doesn’t need any space,Message::Move
needs enough space to store twoi32
values, and so forth. Because only one variant will be used, the most space aMessage
value will need is the space it would take to store the largest of its variants.
The Message
enum is defined as:
enum Message {
Quit,
Move { x: i32, y: i32 },
Write(String),
ChangeColor(i32, i32, i32),
}
What does the bold statement mean in detail?