summaryrefslogtreecommitdiff
path: root/src/utils.rs
blob: 332cd5000a6c9fffa46f5f2096dba0be7ca4cf82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::ffi::CString;
use std::path::Path;

pub trait ToCStr {
    fn to_c_str(&self) -> CString;
}

impl ToCStr for Path {
    fn to_c_str(&self) -> CString {
        CString::from_slice(self.as_vec())
    }
}

impl<'a> ToCStr for &'a str {
    fn to_c_str(&self) -> CString {
        CString::from_slice(self.as_bytes())
    }
}


impl ToCStr for String {
    fn to_c_str(&self) -> CString {
        CString::from_slice(self.as_bytes())
    }
}