aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.rs')
-rw-r--r--src/utils.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs
index fa24029..e1f691c 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -20,3 +20,15 @@ impl ToStr for *const libc::c_char {
}.to_bytes())
}
}
+
+pub trait ToString {
+ fn to_string(&self) -> String;
+}
+
+impl ToString for *const libc::c_char {
+ fn to_string(&self) -> String {
+ unsafe {
+ ffi::CStr::from_ptr(*self).to_string_lossy().into_owned()
+ }
+ }
+}