You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
396 B
15 lines
396 B
4 months ago
|
use std::os::raw::c_char;
|
||
|
use std::slice;
|
||
|
|
||
|
pub fn c_char_to_unsigned(slice: &[c_char]) -> &[u8] {
|
||
|
let ptr = slice.as_ptr().cast::<u8>();
|
||
|
let len = slice.len();
|
||
|
unsafe { slice::from_raw_parts(ptr, len) }
|
||
|
}
|
||
|
|
||
|
pub fn unsigned_to_c_char(slice: &[u8]) -> &[c_char] {
|
||
|
let ptr = slice.as_ptr().cast::<c_char>();
|
||
|
let len = slice.len();
|
||
|
unsafe { slice::from_raw_parts(ptr, len) }
|
||
|
}
|