From 05cb9ccc3f14a861aeb3ae3d7b90e7dbdccfb93b Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sun, 17 Jan 2016 08:37:02 +1100 Subject: [PATCH] Add this back. Still don't seem to need the import std::convert::From, maybe it's implicit. --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index bb48094..aae068c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,6 +92,16 @@ impl<'a> ImStr<'a> { fn as_ptr(&self) -> *const c_char { self.bytes.as_ptr() as *const c_char } } +impl<'a> From<&'a str> for ImStr<'a> { + fn from(value: &'a str) -> ImStr<'a> { + let mut bytes: Vec = value.bytes().collect(); + bytes.push(0); + ImStr { + bytes: Cow::Owned(bytes) + } + } +} + impl From for ImStr<'static> { fn from(mut value: String) -> ImStr<'static> { value.push('\0');