Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Created July 6, 2015 02:07
Show Gist options
  • Save mfpiccolo/3d0f3886318d8017f521 to your computer and use it in GitHub Desktop.
Save mfpiccolo/3d0f3886318d8017f521 to your computer and use it in GitHub Desktop.
Converting Rust Ruby methods
fn ruby_string_to_ref_str<'a>(r_string: *const libc::c_char) -> &'a str {
unsafe { CStr::from_ptr(r_string) }.to_str().unwrap()
}
fn string_to_ruby_string(string: String) -> *const libc::c_char {
CString::new(string).unwrap().into_ptr()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment