Wow, it is possible to implement Index for Vec!

This commit is contained in:
Aleksey Kladov
2017-12-31 20:37:34 +03:00
parent 9e4c288201
commit f16fed18b3
2 changed files with 20 additions and 6 deletions

View File

@@ -81,7 +81,7 @@ impl FileBuilder {
}
fn add_len(&mut self, child: NodeIdx) {
let range = self.nodes[child.0 as usize].range;
let range = self.nodes[child].range;
grow(&mut self.current_parent().range, range);
}
@@ -90,13 +90,13 @@ impl FileBuilder {
}
fn current_parent(&mut self) -> &mut NodeData {
let NodeIdx(idx) = self.current_id();
&mut self.nodes[idx as usize]
let idx = self.current_id();
&mut self.nodes[idx]
}
fn current_sibling(&mut self) -> Option<&mut NodeData> {
let NodeIdx(idx) = self.in_progress.last().unwrap().1?;
Some(&mut self.nodes[idx as usize])
let idx = self.in_progress.last().unwrap().1?;
Some(&mut self.nodes[idx])
}
}