1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::{
cached_node::CachedNode,
interfaces::{
content_categories::{FlowContent, PhrasingContent},
node::NodeBuilder,
},
prelude::*,
};
use moxie::cache;
#[topo::nested]
pub fn text(s: impl AsRef<str>) -> Text {
let text_node = cache(s.as_ref(), |s| document().create_text_node(s));
Text(CachedNode::new(text_node))
}
#[must_use = "needs to be bound to a parent"]
pub struct Text(CachedNode);
impl NodeBuilder for Text {
type Output = Self;
fn build(self) -> Self::Output {
self
}
}
impl crate::interfaces::node::sealed::Memoized for Text {
fn node(&self) -> &CachedNode {
&self.0
}
}
impl crate::interfaces::node::NodeWrapper for Text {}
impl FlowContent for Text {}
impl PhrasingContent for Text {}