Add this back.

Still don't seem to need the import std::convert::From, maybe it's implicit.
This commit is contained in:
Cameron Hart 2016-01-17 08:37:02 +11:00
parent 2d9f63a1b8
commit 05cb9ccc3f

View File

@ -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<u8> = value.bytes().collect();
bytes.push(0);
ImStr {
bytes: Cow::Owned(bytes)
}
}
}
impl From<String> for ImStr<'static> {
fn from(mut value: String) -> ImStr<'static> {
value.push('\0');