Proc macro preparation

This commit is contained in:
Mihai Dinculescu
2022-10-09 09:38:53 +01:00
parent 6d8fc61c0b
commit 7f89887508
29 changed files with 674 additions and 36 deletions

View File

@@ -0,0 +1,14 @@
use std::ffi::CString;
pub fn fixed_c_str_to_string(data: &[i8]) -> String {
let u8slice = unsafe { &*(data as *const _ as *const [u8]) };
let mut value = u8slice.to_vec();
let pos = value.iter().position(|c| *c == 0).unwrap_or(value.len());
value.truncate(pos);
let icao = unsafe { CString::from_vec_unchecked(value) };
icao.to_str().unwrap().to_string()
}