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
42
43
44
45
46
use crate::vdom::Node;
pub trait NodeTrait {
fn is_text(&self) -> bool;
fn is_safe_html(&self) -> bool;
fn unwrap_text(&self) -> &str;
fn unwrap_safe_html(&self) -> &str;
}
impl<MSG> NodeTrait for Node<MSG> {
fn is_text(&self) -> bool {
match self {
Self::Leaf(leaf) => leaf.is_text(),
_ => false,
}
}
fn is_safe_html(&self) -> bool {
match self {
Self::Leaf(leaf) => leaf.is_safe_html(),
_ => false,
}
}
fn unwrap_text(&self) -> &str {
match self {
Self::Leaf(ref leaf) => leaf.unwrap_text(),
_ => panic!("not a leaf node"),
}
}
fn unwrap_safe_html(&self) -> &str {
match self {
Self::Leaf(ref leaf) => leaf.unwrap_safe_html(),
_ => panic!("not a leaf node"),
}
}
}