Closed
Description
I think it would be interesting to use ptr::NonNull
to explicitly document FFI arguments that aren't allowed to be NULL
, so that e.g.:
extern "C" fn call_me_from_c(without_nulls: ptr::NonNull<c_char>)
could be an implementation for:
void call_me_from_c(char *without_nulls) __attribute__((nonnull));
However, ptr::NonNull
doesn't have #[repr(transparent)]
, so I'm not sure if that is sound. Whether it's supposed to be used this way or not, it may be worth explicitly documenting it. Currently its docs don't say anything about FFI compatibility.