-
Notifications
You must be signed in to change notification settings - Fork 60
Proposal: Revert Option<NonNull<c_void>> back to *mut c_void #69
Description
The types and traits in raw-window-handle act as a standard for many other libraries to interact with each other. Changes that break backwards-compatibility require many different projects to be updated. This means that such changes should not be made without a good reason.
In my opinion, there is not a good reason for the change from *mut c_void to Option<NonNull<c_void>>. The two types encode the exact same set of values and there is not really a difference in semantic meaning between the two. This change will require code churn in every single crate that depends on raw-window-handle for essentially no gain. In contrast, the removal of the libc dependency and the addition of TrustedWindowHandle are backwards-compatible changes that crates can benefit from solely by bumping the raw-window-handle version number.
For more explanation as to why I think this is a misuse of NonNull: As explained in the docs, NonNull<T> has two differences from *mut T. First, it is guaranteed not to hold a zero bit pattern, which enables the null pointer optimization. Second, it is covariant over T, whereas *mut T is invariant (irrelevant in raw-window-handle's case). Nothing about NonNull<T> guarantees that it holds a valid pointer to a T (in fact, it has a dangling constructor). This is why Option<NonNull<c_void>> provides no real semantic difference in the case of raw-window-handle.