You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix wrong pointer type of static _dispatch_main_q binding (#343)
While looking at a copy of this code (in another project that uses
`objc2`, which does not yet define `dispatch` integration) this strange
cast immediately stands out. `_dispatch_main_q` is defined here as a
`dispatch_queue_t`, the `queue` argument in `dispatch_data_create()`
is also defined as a `dispatch_queue_t`, yet there is a "borrow" (get
*pointer to*) operation before passing it into the function.
Instead, this `static` field is supposed to be defined as the
`Object` itself, so that any user could take a _pointer to it_
if they wish or need it so. The same is seen in [the `dispatch`
crate]: `_dispatch_main_q` is defined as a `dispatch_object_s`, and
`dispatch_queue_t` is a _typedef_ to a `*mut dispatch_object_s` to match
the above convention.
Note that this is not a bugfix, but merely a readability improvement.
Use of `mut` here is debatable.
[the `dispatch` crate]: https://github.com/SSheldon/rust-dispatch/blob/f540a2d8ccaebf0e87f5805033b9e287e8d01ba5/src/ffi.rs#L33
0 commit comments