1use bumpalo::BumpAllocSafe;
4pub struct Node<'a, Attributes, Children> {
6 attributes: Attributes,
10#[derive(Clone, Copy, Debug)]
11pub enum NodeData<'a> {
12 Element { tag_name: &'a str },
13 Text { text: &'a str },
16#[derive(Clone, Debug)]
17pub struct NodeRef<'a> {
18 pub(crate) data: NodeData<'a>,
19 pub(crate) attributes: &'a [Attribute<'a>],
20 pub(crate) children: &'a [NodeRef<'a>],
23#[derive(Clone, Debug)]
24pub struct Attribute<'a> {
29impl<'a, Attributes, Children> BumpAllocSafe for Node<'a, Attributes, Children>
31 Attributes: BumpAllocSafe,
32 Children: BumpAllocSafe,
36impl<'a, Attributes, Children> From<&'a Node<'a, Attributes, Children>> for NodeRef<'a>
38 Attributes: AsRef<[Attribute<'a>]>,
39 Children: AsRef<[NodeRef<'a>]>,
41 fn from(node: &'a Node<'a, Attributes, Children>) -> NodeRef<'a> {
44 attributes: node.attributes.as_ref(),
45 children: node.children.as_ref(),
50impl<'a, Attributes, Children> From<&'a mut Node<'a, Attributes, Children>> for NodeRef<'a>
52 Attributes: AsRef<[Attribute<'a>]>,
53 Children: AsRef<[NodeRef<'a>]>,
55 fn from(node: &'a mut Node<'a, Attributes, Children>) -> NodeRef<'a> {
58 attributes: node.attributes.as_ref(),
59 children: node.children.as_ref(),
64impl<'a, Attributes, Children> Node<'a, Attributes, Children>
66 Attributes: AsRef<[Attribute<'a>]>,
67 Children: AsRef<[NodeRef<'a>]>,
71 attributes: Attributes,
73 ) -> Node<'a, Attributes, Children> {
74 let data = NodeData::Element { tag_name };
83impl<'a> Node<'a, [Attribute<'a>; 0], [NodeRef<'a>; 0]> {
84 pub fn text(text: &'a str) -> Node<'a, [Attribute<'a>; 0], [NodeRef<'a>; 0]> {
85 let data = NodeData::Text { text };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list