Skip to content

Releases: iwburns/slab-tree

slab_tree v0.3.2

02 May 17:26
Compare
Choose a tag to compare

This release fixes a bug in Tree::remove() where it was possible to cause a panic!() by attempting to remove a Node from the Tree more than once.

Thanks to @clbarnes for this contribution!

slab_tree v0.3.1

07 Apr 03:54
Compare
Choose a tag to compare

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

24 Oct 23:59
34548ca
Compare
Choose a tag to compare

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

24 Aug 17:31
9c6f705
Compare
Choose a tag to compare

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 a Node by its NodeId and return the data that it contained.

Methods changed:

  • NodeMut::remove_first() - added new argument behavior (see above)
  • NodeMut::remove_last() - added new argument behavior (see above)