I tried this on 64bit Linux and it gives 16
:
println!("Results: {}", mem::size_of::<Option<f64>>())
as I understand, this is because of:
pub struct Discriminant<T>(u64, PhantomData<fn() -> T>);
What is the sense in a 64bit discriminant? For code written by hand, 256 will be enough, for generated code 2^16 would be a huge number, and I can not even imagine why need 2^32. Why would it use 64 bits for this?
Why does the compiler not optimize it for the Option
case? 8 bits at the end of the structure should be enough.