mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
18 lines
557 B
Rust
18 lines
557 B
Rust
use crate::dsl::BoxedVNodeProducer;
|
|
use yew::virtual_dom::VText;
|
|
use yew::Component;
|
|
|
|
pub struct VTextProducer<COMP: Component>(Box<dyn FnOnce() -> VText<COMP>>);
|
|
|
|
impl<COMP: Component> VTextProducer<COMP> {
|
|
pub fn new<T: Into<String> + 'static>(text: T) -> Self {
|
|
VTextProducer(Box::new(move || VText::new(text.into())))
|
|
}
|
|
}
|
|
|
|
impl<COMP: Component> From<VTextProducer<COMP>> for BoxedVNodeProducer<COMP> {
|
|
fn from(vtext_prod: VTextProducer<COMP>) -> Self {
|
|
BoxedVNodeProducer::wrap(move |_scope| (vtext_prod.0)().into())
|
|
}
|
|
}
|