Is this possible to cast between raw pointers?
- *const T to *mut T
and
- *mut T to *const T
if its possible pls provide an example
Thank you
Is this possible to cast between raw pointers?
and
if its possible pls provide an example
Thank you
Yes, it's possible, just cast it with the as
operator
fn as_mut_ptr<T>(ptr: *const T) -> *mut T {
ptr as *mut T
}
fn as_const_ptr<T>(ptr: *mut T) -> *const T {
ptr as *const T
}
Notice that this was also posted on reddit:
Please make sure to link other posts when you post the same question multiple times.