Simplify im_str macro

This commit is contained in:
Joonas Javanainen 2017-10-24 20:38:09 +03:00
parent c2ba78e57a
commit 5b0bbc011a
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179

View File

@ -71,13 +71,12 @@ pub struct ImGui {
#[macro_export]
macro_rules! im_str {
($e:tt) => ({
let value = concat!($e, "\0");
unsafe { ::imgui::ImStr::from_utf8_with_nul_unchecked(value.as_bytes()) }
unsafe {
::imgui::ImStr::from_utf8_with_nul_unchecked(concat!($e, "\0").as_bytes())
}
});
($e:tt, $($arg:tt)*) => ({
let mut bytes: Vec<u8> = format!($e, $($arg)*).into();
bytes.push(b'\0');
unsafe { &::imgui::ImString::from_utf8_unchecked(bytes) }
&::imgui::ImString::new(format!($e, $($arg)*))
})
}