The two casts are distinct operations. The first is a coercion of a mutable reference to a pointer and the second is a cast from a pointer of type T to a pointer of type U. If we pretend we had different functions for each cast instead of a type-cast operator in as, I think of this as pointer_cast::<*mut c_void>(mut_to_pointer::<*mut OCIError>(&mut errhp_ctl)). If you leave out the call to mut_to_pointer, the input to pointer_cast will be wrong, thus the error.
OK, that must be it. Thanks.
So as I do not have a way to check it, basically having &raw makes it possible to get rid of the first casting/coersion, i.e. as *mut *mu _
Is that correct?
when you use the regular borrow operator &mut errhp_ctl, you get a reference to errhp_ctl, which needs to be coerced to the raw pointer with the as operator first, and then be casted to the target pointer type.
when you use raw borrow operator &raw mut errhp_ctl, you get a raw pointer to errhp_ctl directly, so you only need to cast it once.