@@ -150,7 +150,7 @@ impl<K, V, Type> NodeRef<marker::Owned, K, V, Type> {
150
150
/// Mutably borrows the owned node. Unlike `reborrow_mut`, this is safe,
151
151
/// because the return value cannot be used to destroy the node itself,
152
152
/// and there cannot be other references to the tree (except during the
153
- /// process of `into_iter` or `drop`, but that is a horrific already).
153
+ /// process of `into_iter` or `drop`, but that is horrific already).
154
154
pub fn borrow_mut ( & mut self ) -> NodeRef < marker:: Mut < ' _ > , K , V , Type > {
155
155
NodeRef { height : self . height , node : self . node , _marker : PhantomData }
156
156
}
@@ -192,7 +192,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
192
192
193
193
let internal_node = NodeRef { height : self . height , node : top, _marker : PhantomData } ;
194
194
* self = internal_node. first_edge ( ) . descend ( ) ;
195
- self . borrow_mut ( ) . clear_parent_link ( ) ;
195
+ self . clear_parent_link ( ) ;
196
196
197
197
unsafe {
198
198
Global . deallocate ( top. cast ( ) , Layout :: new :: < InternalNode < K , V > > ( ) ) ;
@@ -611,18 +611,19 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
611
611
}
612
612
613
613
impl < ' a , K : ' a , V : ' a > NodeRef < marker:: Mut < ' a > , K , V , marker:: LeafOrInternal > {
614
- /// Set or clear the node's link to its parent edge,
614
+ /// Sets the node's link to its parent edge,
615
615
/// without invalidating other references to the node.
616
616
fn set_parent_link ( & mut self , parent : NonNull < InternalNode < K , V > > , parent_idx : usize ) {
617
617
let leaf = Self :: as_leaf_ptr ( self ) ;
618
618
unsafe { ( * leaf) . parent = Some ( parent) } ;
619
619
unsafe { ( * leaf) . parent_idx . write ( parent_idx as u16 ) } ;
620
620
}
621
+ }
621
622
622
- /// Clear the node's link to its parent edge.
623
- /// This only makes sense when there are no other references to the node .
623
+ impl < K , V > NodeRef < marker :: Owned , K , V , marker :: LeafOrInternal > {
624
+ /// Clears the root's link to its parent edge .
624
625
fn clear_parent_link ( & mut self ) {
625
- let leaf = Self :: as_leaf_mut ( self ) ;
626
+ let leaf = NodeRef :: as_leaf_mut ( & mut self . borrow_mut ( ) ) ;
626
627
leaf. parent = None ;
627
628
}
628
629
}
@@ -720,9 +721,9 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
720
721
ForceResult :: Internal ( internal) => {
721
722
let node = ptr:: read ( internal. reborrow ( ) . edge_at ( idx + 1 ) ) ;
722
723
let mut edge = Root { node, height : internal. height - 1 , _marker : PhantomData } ;
723
- // In practice , clearing the parent is a waste of time , because we will
724
+ // Currently , clearing the parent link is superfluous , because we will
724
725
// insert the node elsewhere and set its parent link again.
725
- edge. borrow_mut ( ) . clear_parent_link ( ) ;
726
+ edge. clear_parent_link ( ) ;
726
727
Some ( edge)
727
728
}
728
729
} ;
@@ -748,9 +749,9 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
748
749
ForceResult :: Internal ( mut internal) => {
749
750
let node = slice_remove ( internal. reborrow_mut ( ) . into_edge_area_slice ( ) , 0 ) ;
750
751
let mut edge = Root { node, height : internal. height - 1 , _marker : PhantomData } ;
751
- // In practice , clearing the parent is a waste of time , because we will
752
+ // Currently , clearing the parent link is superfluous , because we will
752
753
// insert the node elsewhere and set its parent link again.
753
- edge. borrow_mut ( ) . clear_parent_link ( ) ;
754
+ edge. clear_parent_link ( ) ;
754
755
755
756
internal. correct_childrens_parent_links ( 0 ..old_len) ;
756
757
0 commit comments