From 706428acbe134d54553bf3fb52bfcd344c707e11 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 2 Dec 2015 02:44:45 +0100 Subject: [PATCH] Random tests. --- src/triehash.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/triehash.rs b/src/triehash.rs index afc07a7bf..33d35513c 100644 --- a/src/triehash.rs +++ b/src/triehash.rs @@ -190,9 +190,12 @@ fn hash256rlp(input: &[(Vec, Vec)], pre_len: usize, stream: &mut RlpStre // iterate over all possible nibbles for i in 0..16 { // cout how many successive elements have same next nibble - let len = input[begin..].iter() - .map(| pair | pair.0[pre_len] ) - .take_while(|&q| q == i).count(); + let len = match begin < input.len() { + true => input[begin..].iter() + .map(| pair | pair.0[pre_len] ) + .take_while(|&q| q == i).count(), + false => 0 + }; // if at least 1 successive element has the same nibble // append their suffixes