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
47
48
use super::NodeIdx;
use crate::Node;
use std::fmt;

/// Append a vector of child nodes to a parent node id.
#[derive(PartialEq)]
pub struct AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG> {
    /// the tag of the node we are appending the children into
    pub tag: &'a TAG,
    /// index of the node we are going to append the children into
    pub node_idx: NodeIdx,
    /// children nodes to be appended and their corresponding new_node_idx
    pub children: Vec<(NodeIdx, &'a Node<NS, TAG, ATT, VAL, EVENT, MSG>)>,
}

impl<'a, NS, TAG, ATT, VAL, EVENT, MSG>
    AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG>
{
    /// create a new AppendChildren patch
    pub fn new(
        tag: &'a TAG,
        node_idx: NodeIdx,
        children: Vec<(NodeIdx, &'a Node<NS, TAG, ATT, VAL, EVENT, MSG>)>,
    ) -> Self {
        AppendChildren {
            tag,
            node_idx,
            children,
        }
    }
}

impl<'a, NS, TAG, ATT, VAL, EVENT, MSG> fmt::Debug
    for AppendChildren<'a, NS, TAG, ATT, VAL, EVENT, MSG>
where
    NS: fmt::Debug,
    TAG: fmt::Debug,
    ATT: fmt::Debug,
    VAL: fmt::Debug,
{
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("AppendChildren")
            .field("tag", &self.tag)
            .field("node_idx", &self.node_idx)
            .field("children", &self.children)
            .finish()
    }
}