aboutsummaryrefslogtreecommitdiff
path: root/src/yellow/red.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/yellow/red.rs')
-rw-r--r--src/yellow/red.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/yellow/red.rs b/src/yellow/red.rs
index 8329ec5b2..a30318c6e 100644
--- a/src/yellow/red.rs
+++ b/src/yellow/red.rs
@@ -61,9 +61,12 @@ impl RedNode {
61 self.green.children().len() 61 self.green.children().len()
62 } 62 }
63 63
64 pub(crate) fn nth_child(&self, idx: usize) -> ptr::NonNull<RedNode> { 64 pub(crate) fn get_child(&self, idx: usize) -> Option<ptr::NonNull<RedNode>> {
65 if idx >= self.n_children() {
66 return None
67 }
65 match &self.children.read().unwrap()[idx] { 68 match &self.children.read().unwrap()[idx] {
66 Some(child) => return child.into(), 69 Some(child) => return Some(child.into()),
67 None => (), 70 None => (),
68 } 71 }
69 let mut children = self.children.write().unwrap(); 72 let mut children = self.children.write().unwrap();
@@ -78,7 +81,7 @@ impl RedNode {
78 RedNode::new_child(green_children[idx].clone(), self.into(), start_offset, idx); 81 RedNode::new_child(green_children[idx].clone(), self.into(), start_offset, idx);
79 children[idx] = Some(child) 82 children[idx] = Some(child)
80 } 83 }
81 children[idx].as_ref().unwrap().into() 84 Some(children[idx].as_ref().unwrap().into())
82 } 85 }
83 86
84 pub(crate) fn parent(&self) -> Option<ptr::NonNull<RedNode>> { 87 pub(crate) fn parent(&self) -> Option<ptr::NonNull<RedNode>> {