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
//! The module contains a html primitives.

mod attr;
mod html_element;
mod value;

pub use attr::Attribute;
pub use html_element::HtmlElement;
pub use value::HtmlValue;

/// A visitor which traverses a HTML elements tree.
pub trait HtmlVisitor {
    /// Visit an element.
    fn visit_element(&mut self, table: &HtmlElement) -> bool;
}

impl<T> HtmlVisitor for &mut T
where
    T: HtmlVisitor,
{
    fn visit_element(&mut self, table: &HtmlElement) -> bool {
        T::visit_element(self, table)
    }
}

/// A visitor which traverses a HTML elements tree, while mutating the tree.
pub trait HtmlVisitorMut {
    /// Visit an element.
    fn visit_element_mut(&mut self, table: &mut HtmlElement) -> bool;
}

impl<T> HtmlVisitorMut for &mut T
where
    T: HtmlVisitorMut,
{
    fn visit_element_mut(&mut self, table: &mut HtmlElement) -> bool {
        T::visit_element_mut(self, table)
    }
}