Display to rsx

This commit is contained in:
2026-01-30 23:25:33 +01:00
parent bf6fa42d96
commit 4e2d4662d1
+11
View File
@@ -2,6 +2,7 @@ use std::sync::Arc;
use crate::{ use crate::{
component::{Context, Scope}, component::{Context, Scope},
render::Point,
state::HookDependency, state::HookDependency,
View, View,
}; };
@@ -85,3 +86,13 @@ impl ToRsx for &Rsx {
Rsx(self.0.clone()) Rsx(self.0.clone())
} }
} }
impl<T: std::fmt::Display> ToRsx for T {
fn to_rsx(&self) -> Rsx {
let s = self.to_string();
Rsx(vec![RsxScope::Static(Arc::new(move |scope| {
let s = s.clone();
scope.view(Arc::new(move |ctx| ctx.draw_text(Point { x: 0, y: 0 }, &s)))
}))])
}
}