use std::ffi::CString;
pub enum Outcome {
Ok(*mut ()),
Err(CString),
}
impl<T, E> From<Result<T, E>> for Outcome
where
E: ToString,
{
fn from(result: Result<T, E>) -> Outcome {
match result {
Ok(b) => Outcome::Ok(Box::leak(Box::new(b)) as *mut T as *mut ()),
Err(e) => Outcome::Err(
CString::new(e.to_string().replace('\0', "\\0")).expect("nuls have been escaped"),
),
}
}
}