Description
libc::Nullable
exists as an Option
-equivalent that is suitable for using with liblibc
without requiring libstd
. It seems the appropriate type to use for nullable function pointers, e.g. Nullable<extern "C" fn (int)>
. But doing this is making the implicit assumption that Nullable
benefits from the null-pointer optimization, i.e. that this type has the same size as *()
. I think we should statically guarantee this by adding an attribute that guarantees that Nullable<T>
can only be used with a type parameter that allows it to use the null-pointer optimization. This means I can say Nullable<extern "C" fn (int)>
, but I can't say Nullable<uint>
, nor Nullable<*u32>
(because *u32
is already nullable, and therefore the null-pointer optimization doesn't apply).