-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.