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
Currently only the last line in the example below doesn't compile.
fn fref(_: &u8) {}
fn fptr(_: *const u8) {}
let mut v = 0u8;
fref(&v);
fref(&mut v);
fptr(&v as *const u8);
fptr(&mut v as *mut u8); // error: mismatched types: expected `*const u8`, found `*mut u8` (values differ in mutability)
The conversion *mut T -> *const T is safe and consistent both with Rust references (&mut T coerces to &T) and C pointers (T* is implicitly convertible to const T*). I don't see the reasons why it is not allowed.
The text was updated successfully, but these errors were encountered:
Currently only the last line in the example below doesn't compile.
The conversion
*mut T
->*const T
is safe and consistent both with Rust references (&mut T
coerces to&T
) and C pointers (T*
is implicitly convertible toconst T*
). I don't see the reasons why it is not allowed.The text was updated successfully, but these errors were encountered: