mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-22 13:21:03 +00:00
feat(core/rust): add useful macros
This commit is contained in:
parent
73c493d118
commit
610c832dee
@ -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()
|
||||
}};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user