← Back to context Comment by tempodox 2 years ago I find this strange: &mut h as *mut _ as *mut _ What is going on here? 4 comments tempodox Reply dwattttt 2 years ago 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. mkeeter 2 years ago It's doing the following cast: &mut DeviceHandle -> *mut DeviceHandle -> *mut c_void (with the pointer types being solved for automatically by the compiler) evrimoztamur 2 years ago It dereferences a mutable reference to h twice, ignoring its type with _s. I suppose this implies that h is a reference type itself. muricula 2 years ago No dereferences, just casts. It shouldn't generate any loads/reads from memory.
dwattttt 2 years ago 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.
mkeeter 2 years ago It's doing the following cast: &mut DeviceHandle -> *mut DeviceHandle -> *mut c_void (with the pointer types being solved for automatically by the compiler)
evrimoztamur 2 years ago It dereferences a mutable reference to h twice, ignoring its type with _s. I suppose this implies that h is a reference type itself. muricula 2 years ago No dereferences, just casts. It shouldn't generate any loads/reads from memory.
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:
(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.
No dereferences, just casts. It shouldn't generate any loads/reads from memory.