microsoft/windows-rs

`windows_bindgen` should make use of `Option<NonNull<T>>` instead of `Option<*mut/const T>` for `ptr` params.

chernoivanenkoofficial opened this issue · 0 comments

Suggestion

Currently, a lot of bindings for optional in or out pointer parameters of bindings are using Option around the possibly null pointer, which:

  1. Makes a param size larger then a size of a ptr,
  2. Requires casting to raw pointer to be a real None check and not a no-op.

Making binding rely on Option<NonNull<T>> should be a general and quite easy improvement (though, it will not allow to express if the param can be mutated by bound function). Other then this little drawback, are there any other reasons not to opt for this kind of binding generating?