Is it valid to use ptr::NonNull in FFI?
问题 Rust has the ptr::NonNull type that represents a non- NULL pointer. Is it safe to use this type in FFI? Is it guaranteed to have same binary representation (ignoring non-FFI context such as Option optimizations), alignment, register usage as *mut T ? For example, could I implement this interface: void call_me_from_c(char *without_nulls) __attribute__((nonnull)); with extern "C" fn call_me_from_c(without_nulls: ptr::NonNull<c_char>) I don't expect this to do anything (apart from causing UB