1
2
3
4
5
6
7
8
9
10
11
use std::ffi::CStr;
use std::os::raw::c_char;

/// converts '*const c_char' to '&str'
///
pub fn cchar_to_str(cchar: *const c_char) -> &'static str {
    let c_buf: *const c_char = cchar;
    let c_str: &CStr = unsafe { CStr::from_ptr(c_buf) };
    c_str.to_str().unwrap()
}