A surprising enum size optimization in the Rust compiler

Enums are one of the most popular features in Rust. An enum is type whose value is one of a specified set of variants. /// Foo is either a 32-bit integer or character. enum Foo { Int(u32), Char(char), } Values of type Foo are either integers (e.g. the variant Foo::Int(3) with a payload of 3) or characters (e.g. the variant Foo::Char('A') with a payload of 'A'). If you think of structs as being the…