mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-17 08:28:44 +00:00
Simplify im_str macro
This commit is contained in:
parent
c2ba78e57a
commit
5b0bbc011a
@ -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)*))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user