Originally posted by Unscript
View Post
Thus, bare pointers in rust behave as if you used the keyword restrict in C.
Naively assuming C memory layout of a type can also ask for trouble in the unsafe-context.
With the default layout, the compiler will try its best to apply size optimizations for nested enum types. For example an Option<&U> has the same size as &U. Knowing the pointer (which is used under the hood) cannot be NULL, the None variant of the Option will typically get encoded as NULL.
You can always switch to C layout though, if required.
Comment