Skip to content

Instantly share code, notes, and snippets.

@MarkJr94
Created September 15, 2013 02:09
Show Gist options
  • Save MarkJr94/6567452 to your computer and use it in GitHub Desktop.
Save MarkJr94/6567452 to your computer and use it in GitHub Desktop.
fn slice_from_c_str<'a>(cstr: *c_char) -> &'a str {
unsafe {
cast::transmute_region(str::raw::c_str_to_static_slice(cstr))
}
}
config.rs:49 cast::transmute_region(str::raw::c_str_to_static_slice(cstr))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
config.rs:48:4: 50:5 error: mismatched types: expected `&'a str` but found `&<V1>` (expected &'a str but found &-ptr)
config.rs:48 unsafe {
config.rs:49 cast::transmute_region(str::raw::c_str_to_static_slice(cstr))
config.rs:50 }
error: aborting due to 2 previous errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment