vapoursynth4_rs/
utils.rs

1use std::ffi::CString;
2
3pub trait ToCString {
4    fn into_cstring_lossy(self) -> CString;
5}
6
7impl ToCString for String {
8    fn into_cstring_lossy(mut self) -> CString {
9        self.retain(|c| c != '\0');
10        unsafe { CString::from_vec_unchecked(self.into_bytes()) }
11    }
12}
13
14impl ToCString for &str {
15    fn into_cstring_lossy(self) -> CString {
16        unsafe { CString::from_vec_unchecked(self.bytes().filter(|&c| c != b'\0').collect()) }
17    }
18}
19
20pub use crate::ffi::vs_make_version as make_version;
21
22pub use crate::ffi::helper::*;