From 610c832deefc7087c4f05080407b0e322cf63e94 Mon Sep 17 00:00:00 2001 From: grdddj Date: Thu, 4 May 2023 16:01:11 +0200 Subject: [PATCH] feat(core/rust): add useful macros --- core/embed/rust/src/ui/macros.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/embed/rust/src/ui/macros.rs b/core/embed/rust/src/ui/macros.rs index 8ccea9d9c8..c0e239e9e7 100644 --- a/core/embed/rust/src/ui/macros.rs +++ b/core/embed/rust/src/ui/macros.rs @@ -4,3 +4,23 @@ macro_rules! include_res { include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/ui/", $filename)) }; } + +#[allow(unused_macros)] // Only used in TR so far. +/// Concatenates arbitrary amount of slices into a String. +macro_rules! build_string { + ($max:expr, $($string:expr),+) => { + { + let mut new_string = String::<$max>::new(); + $(unwrap!(new_string.push_str($string));)+ + new_string + } + } +} + +#[cfg(feature = "ui_debug")] +/// Transforms integer into string slice. For example for printing. +macro_rules! inttostr { + ($int:expr) => {{ + heapless::String::<10>::from($int).as_str() + }}; +}