In Rust, unlike in C, enum
s are tagged unions. That is, the enum
knows which value it holds. So 8 bytes wouldn’t be enough because there would be no room for the tag.
More Related Contents:
- Why is a trait not implemented for a type that clearly has it implemented?
- How can I include a module from another file from the same project?
- What does “Sized is not implemented” mean?
- Deriving a trait results in unexpected compiler error, but the manual implementation works
- How do I implement Copy and Clone for a type that contains a String (or any type that doesn’t implement Copy)?
- Mutably borrow one struct field while borrowing another in a closure
- What makes something a “trait object”?
- Change enum variant while moving the field to the new variant
- When is it useful to define multiple lifetimes in a struct?
- Can I write an Iterator that mutates itself and then yields a reference into itself?
- How to update-or-insert on a Vec?
- How do I include the end value in a range?
- How do I specify lifetime parameters in an associated type?
- How do I invoke a system command and capture its output?
- How to return a string (or similar) from Rust in WebAssembly?
- Can I destructure a tuple without binding the result to a new variable in a let/match/for statement?
- What is the difference between Copy and Clone?
- Is it possible to have stack allocated arrays with the size determined at runtime in Rust?
- How to format output to a byte array with no_std and no allocator?
- What is the right way to allocate data to pass to an FFI call?
- How can I distinguish between a deserialized field that is missing and one that is null?
- Cannot create a generic function that uses a literal zero
- Is there a way to combine multiple traits in order to define a new trait? [duplicate]
- How to avoid temporary allocations when using a complex key for a HashMap?
- Why does compilation not fail when a member of a moved value is assigned to?
- What does “missing lifetime specifier” mean when storing a &str in a structure?
- What is the purpose of the unit type in Rust?
- Why does the Rust compiler request I constrain a generic type parameter’s lifetime (error E0309)?
- Cannot pass self as callback parameter due to double borrowing
- How do I create a HashMap with type erased keys?