Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ impl<T> Node<T> {
None
}

/// Returns a mutable reference to the parent node of this node,
/// or None if it is the root node. Ensure that there is only one reference to the returned value.
/// Also see the `parent` method.
pub unsafe fn parent_mut( &self ) -> Option<&mut Node<T>> {
let mut node = self.non_null();
while let Some( parent ) = node.as_ref().up {
if parent.as_ref().is_forest() {
node = parent;
} else {
return Some( &mut *parent.as_ptr() );
}
}
None
}


/// Inserts sib tree before `self`.
/// The newly inserted node will not be iterated over by the currently running iterator.
///
Expand Down