Releases: iwburns/slab-tree
slab_tree v0.3.2
slab_tree v0.3.1
This release fixes a bug in Tree::remove()
where removing the root node in a Tree caused the Tree to think it had a root even though it didn't.
Thanks to @M-Adoo for this contribution!
slab_tree v0.3.0
This release changes the return type on several NodeRef
methods to include the lifetime of the Tree
that the NodeRef
belongs to.
Method Name | Old Return | New Return |
---|---|---|
data |
&T |
&'a T |
ancestors |
impl Iterator<Item = NodeRef<T>> |
Ancestors<'a, T> |
children |
impl Iterator<Item = NodeRef<T>> |
NextSiblings<'a, T> |
traverse_pre_order |
impl Iterator<Item = NodeRef<T>> |
PreOrder<'a, T> |
traverse_post_order |
impl Iterator<Item = NodeRef<T>> |
PostOrder<'a, T> |
traverse_level_order |
impl Iterator<Item = NodeRef<T>> |
LevelOrder<'a, T> |
This is allows more flexible access to data and iterator methods. One example of this is a function which returns an iterator over data (possibly filtered or otherwise modified) from the a Tree:
fn even_children(tree: &Tree<i32>) -> impl Iterator<Item = &i32> {
tree.root()
.expect("root doesn't exist?")
.children()
.map(|node_ref| node_ref.data())
.filter(|&data| data % 2 == 0)
}
This would not previously have been expressible because rustc
had no way to determine an appropriate lifetime for the returned iterator.
Thanks to @xiaoniu-578fa6bff964d005 for this contribution!
slab_tree v0.2.0
This release re-works the way all node-removal methods work.
These methods now require a RemoveBehavior
and will now either DropChildren
or OrphanChildren
depending on the behavior provided.
Methods added:
Tree::remove()
- Remove aNode
by itsNodeId
and return the data that it contained.
Methods changed:
NodeMut::remove_first()
- added new argumentbehavior
(see above)NodeMut::remove_last()
- added new argumentbehavior
(see above)