diff --git a/sealable-trie/src/nodes.rs b/sealable-trie/src/nodes.rs index 29a09069..2814e714 100644 --- a/sealable-trie/src/nodes.rs +++ b/sealable-trie/src/nodes.rs @@ -208,12 +208,16 @@ impl<'a, P, S> Node<'a, P, S> { // tag = 0b100v_0000 where v indicates whether the child is // a value reference. let tag = 0x80 | (u8::from(child.is_value()) << 4); - // XXX - if let Ok(len) = key.encode_into(key_buf, tag) { - buf[len..len + 32].copy_from_slice(child.hash().as_slice()); - len + 32 - } else { - return hash_extension_slow_path(*key, child); + match key.encode_into(key_buf, tag) { + Ok(len) => { + buf[len..len + 32] + .copy_from_slice(child.hash().as_slice()); + len + 32 + } + Err(bits::EncodeError::EmptySlice) => { + return hash_extension_slow_path(*key, child); + } + Err(bits::EncodeError::SliceTooLong) => unreachable!(), } } };