shardtree: Fix pruning of annotated `Parent` nodes with `Nil` children.

The current behavior of `unite` incorrectly discards annotation data.
This commit is contained in:
Kris Nuttycombe 2024-06-25 15:04:12 -06:00
parent 08d3e23977
commit f5adcd5a2c
2 changed files with 4 additions and 1 deletions

View File

@ -24,6 +24,9 @@ and this project adheres to Rust's notion of
- Fixes an error that could occur if an inserted `Frontier` node was
interpreted as a node that had actually had its value observed as though it
had been inserted using the ordinary tree insertion methods.
- Fixes an error in an internal method that could result in subtree root
annotation data being discarded when pruning a `Parent` node having
`Nil` nodes for both its left and right children.
## [0.3.1] - 2024-04-03

View File

@ -312,7 +312,7 @@ impl<H: Hashable + Clone + PartialEq> PrunableTree<H> {
/// `level` must be the level of the two nodes that are being joined.
pub(crate) fn unite(level: Level, ann: Option<Arc<H>>, left: Self, right: Self) -> Self {
match (left, right) {
(Tree(Node::Nil), Tree(Node::Nil)) => Tree::empty(),
(Tree(Node::Nil), Tree(Node::Nil)) if ann.is_none() => Tree::empty(),
(Tree(Node::Leaf { value: lv }), Tree(Node::Leaf { value: rv }))
// we can prune right-hand leaves that are not marked or reference leaves; if a
// leaf is a checkpoint then that information will be propagated to the replacement