I have a function
extern "C" {
fn log_impl(ptr: *const u8);
}
fn log(s: &str) {
log_impl(s.as_bytes() as *const u8);
}
This gives me the following error:
error[E0606]: casting `&[u8]` as `*const u8` is invalid
--> src/main.rs:6:14
|
6 | log_impl(s.as_bytes() as *const u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
The most similar question to what I'm trying to do is Converting a str to a &[u8].