Added rsx iteration

This commit is contained in:
2025-08-12 23:40:56 -04:00
parent fde8ad17d6
commit 9a03f241d8
3 changed files with 27 additions and 22 deletions
+14
View File
@@ -240,6 +240,20 @@ macro_rules! rsx {
/// Would produce a nested `Rsx` tree of static and dynamic widgets.
#[macro_export]
macro_rules! rsx_inner {
// for loop (iter)
($r:expr, for $n:ident in $state:ident { $($inner:tt)* } $($rest:tt)*) => {
$r.iter({
let $state = $state.clone();
move || {
let mut r = $crate::frontend::Rsx(Vec::new());
for $n in $state.get().iter() {
r.expand_nr($crate::rsx!{ $($inner)* });
}
r
}}, Box::new($state));
$crate::rsx_inner! { $r, $($rest)* };
};
// static
($r:expr, $(@$comp:expr;)* static $s:literal $($rest:tt)*) => {
let w = $crate::widget::StaticWidget::new(Box::new(format!($s)));