Closed
Description
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.
Metadata
Metadata
Assignees
Labels
No labels