Skip to content

Commit

Permalink
Don't reduce when target cell is smaller than leaf cell
Browse files Browse the repository at this point in the history
  • Loading branch information
JayKickliter committed Mar 14, 2023
1 parent 0680a30 commit c6bb8ad
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,10 @@ impl<V> Node<V> {
V: Copy,
F: FnMut(u8, &[V]) -> V,
{
if let Self::Leaf(val) = self {
return Some(*val);
}

match (digits.next(), self) {
(Some(_digit), Self::Leaf(_)) => unreachable!(),
// Can't reduce when the target cell is higher resolution
// than this leaf node.
(Some(_digit), Self::Leaf(_)) => None,
(Some(digit), Self::Parent(children)) => match &children.as_slice()[digit as usize] {
Some(node) => node.reduce(res + 1, digits, f),
None => None,
Expand Down

0 comments on commit c6bb8ad

Please sign in to comment.