mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-01 03:18:12 +00:00
rust: add useful macros
This commit is contained in:
parent
a6d1dcbb03
commit
d34c1eed75
@ -4,3 +4,23 @@ macro_rules! include_res {
|
|||||||
include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/ui/", $filename))
|
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();
|
||||||
|
$(new_string.push_str($string).unwrap();)+
|
||||||
|
new_string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused_macros)] // Mostly for debugging purposes.
|
||||||
|
/// 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