← Back to context

Comment by tempodox

2 years ago

I find this strange:

  &mut h as *mut _ as *mut _

What is going on here?

It's a bit of a song and dance; you can turn a &mut T into a *mut T, and you can cast a *mut T into a *mut anything, but you can't do it in one step.

It's doing the following cast:

    &mut DeviceHandle -> *mut DeviceHandle -> *mut c_void

(with the pointer types being solved for automatically by the compiler)

It dereferences a mutable reference to h twice, ignoring its type with _s. I suppose this implies that h is a reference type itself.