Q patch just recently landed to do that optimization for Option types
containing a pointer. Options wrapping a value type still need an extra
word however in order to distinguish between the Some/None cases though.

On Wednesday, May 29, 2013, Ziad Hatahet wrote:

> Hi all,
>
> Does using Option incur a runtime cost (like increased memory usage)
> compared to a hypothetical case if Rust had a NULL type in the language? Or
> does it get optimized away, such that it is akin to using NULL in the first
> place (albeit safer of course)?
>
> I have not looked at any assemblies, ut my intuition says that a
> comparison with None is a single-word check, so it should be pretty fast.
>
> Thanks
>
> --
> Ziad
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to