diff options
Diffstat (limited to 'src/tree/mod.rs')
-rw-r--r-- | src/tree/mod.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tree/mod.rs b/src/tree/mod.rs index b90a5d7d3..7c4162a68 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs | |||
@@ -70,7 +70,7 @@ impl<'f> Node<'f> { | |||
70 | } | 70 | } |
71 | 71 | ||
72 | fn data(&self) -> &'f NodeData { | 72 | fn data(&self) -> &'f NodeData { |
73 | &self.file.nodes[self.idx.0 as usize] | 73 | &self.file.nodes[self.idx] |
74 | } | 74 | } |
75 | 75 | ||
76 | fn as_node(&self, idx: Option<NodeIdx>) -> Option<Node<'f>> { | 76 | fn as_node(&self, idx: Option<NodeIdx>) -> Option<Node<'f>> { |
@@ -102,3 +102,17 @@ struct NodeData { | |||
102 | first_child: Option<NodeIdx>, | 102 | first_child: Option<NodeIdx>, |
103 | next_sibling: Option<NodeIdx>, | 103 | next_sibling: Option<NodeIdx>, |
104 | } | 104 | } |
105 | |||
106 | impl ::std::ops::Index<NodeIdx> for Vec<NodeData> { | ||
107 | type Output = NodeData; | ||
108 | |||
109 | fn index(&self, NodeIdx(idx): NodeIdx) -> &NodeData { | ||
110 | &self[idx as usize] | ||
111 | } | ||
112 | } | ||
113 | |||
114 | impl ::std::ops::IndexMut<NodeIdx> for Vec<NodeData> { | ||
115 | fn index_mut(&mut self, NodeIdx(idx): NodeIdx) -> &mut NodeData { | ||
116 | &mut self[idx as usize] | ||
117 | } | ||
118 | } \ No newline at end of file | ||