summaryrefslogtreecommitdiff
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
new file mode 100644
index 00000000..a6e279af
--- /dev/null
+++ b/src/utils.rs
@@ -0,0 +1,18 @@
+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 ToCStr for String {
+ fn to_c_str(&self) -> CString {
+ CString::from_slice(self.as_bytes())
+ }
+}