From c6bb8ad8328779e6c59d34f001a2f145c0eae441 Mon Sep 17 00:00:00 2001 From: Jay Kickliter Date: Tue, 14 Mar 2023 12:11:54 -0600 Subject: [PATCH] Don't reduce when target cell is smaller than leaf cell --- src/node.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/node.rs b/src/node.rs index e603f5d..db47e54 100644 --- a/src/node.rs +++ b/src/node.rs @@ -150,12 +150,10 @@ impl Node { 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,