News for hackers. Stuff that matters.
Re:Announcing Rust 1.20 by Animats on Friday September 01, 2017 @01:29AM (#15146353)
If T is a reference type, doesn't Rust do an optimization where <Option<T>>> is implemented by using null pointers?
Re:Announcing Rust 1.20 by kevincox on Friday September 01, 2017 @03:41AM (#15146826)
Yes. This optimization is expected to be expanded in the future but there are currently "NonZero" types. Rust notices this and uses the zero value as the enum descriminant.

So in this case the code generated is idential to a nullable pointer.

Re:Announcing Rust 1.20 by sanxiyn on Friday September 01, 2017 @04:00AM (#15146893)
Yes, but that doesn't help when T is not a reference type.
Re:Announcing Rust 1.20 by Animats on Friday September 01, 2017 @06:13PM (#15152785)
If it's not a reference type, then the Option enum value is probably small relative to the rest of the data in the type.
Re:Announcing Rust 1.20 by __s on Saturday September 02, 2017 @07:29PM (#15158815)
Option<i32> is 8 bytes