From e1f59b1b466b7f0deda42dfc3f4e91a892a4d9ee Mon Sep 17 00:00:00 2001 From: Janis Date: Thu, 6 Apr 2023 11:47:34 +0200 Subject: [PATCH] using BoxedNode alias instead of Rc --- btrfs/src/v2/tree.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/btrfs/src/v2/tree.rs b/btrfs/src/v2/tree.rs index 0aecf25..5209f66 100644 --- a/btrfs/src/v2/tree.rs +++ b/btrfs/src/v2/tree.rs @@ -25,7 +25,7 @@ pub struct BTreeLeafNode { #[derive(Debug, Clone)] pub enum NodePtr { Unvisited(KeyPtr), - Visited { key: KeyPtr, node: Rc }, // TODO: this doesnt need to be an Rc, can just be a NonNull with manual memory management + Visited { key: KeyPtr, node: BoxedNode }, // TODO: this doesnt need to be an Rc, can just be a NonNull with manual memory management } impl NodePtr { @@ -36,7 +36,7 @@ impl NodePtr { } } - pub fn node(&self) -> Option<&Rc> { + pub fn node(&self) -> Option<&BoxedNode> { match self { NodePtr::Unvisited(_) => None, NodePtr::Visited { node, .. } => Some(&node), @@ -62,7 +62,7 @@ impl BTreeInternalNode { &self, idx: usize, volume: &super::volume::Volume, - ) -> Result> { + ) -> Result { match self.children.get(idx) { Some(child) => self.visit_child_inner(child, volume), None => Err(Error::OutOfBounds { @@ -76,7 +76,7 @@ impl BTreeInternalNode { &self, child: &Cell, volume: &super::volume::Volume, - ) -> Result> { + ) -> Result { match unsafe { &*child.as_ptr() } { NodePtr::Unvisited(keyptr) => { let node = volume @@ -105,7 +105,7 @@ impl BTreeInternalNode { pub fn visit_children<'a, 'b, R: super::Read>( &'a self, volume: &'b super::volume::Volume, - ) -> impl Iterator>)> + 'a + ) -> impl Iterator)> + 'a where 'b: 'a, { @@ -680,7 +680,7 @@ where } } - pub fn new(volume: Rc>, start: Rc, end: Rc) -> Self { + pub fn new(volume: Rc>, start: BoxedNode, end: BoxedNode) -> Self { Self::from_handles(volume, NodeHandle::start(start), NodeHandle::end(end)) }