diff options
| author | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-03-23 07:50:00 +0100 |
|---|---|---|
| committer | Dirk Van Haerenborgh <vhdirk@gmail.com> | 2018-03-23 07:50:00 +0100 |
| commit | 188068f051976f8dd4bf1b0da5fcb4bc2c6ae185 (patch) | |
| tree | 339a0eb7b9d72d8f716e153a77c1052be0b5f58d /src/utils.rs | |
| parent | ba417206ed8bb2341dcad5655d91ad09f6a0f073 (diff) | |
| download | mail-188068f051976f8dd4bf1b0da5fcb4bc2c6ae185.tar.gz | |
cleanup
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 12 |
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() + } + } +} |
