diff --git a/consensus/ssz_types/src/variable_list.rs b/consensus/ssz_types/src/variable_list.rs index 774d4a358..599e4f5b6 100644 --- a/consensus/ssz_types/src/variable_list.rs +++ b/consensus/ssz_types/src/variable_list.rs @@ -247,8 +247,10 @@ where bytes .chunks(T::ssz_fixed_len()) - .map(|chunk| T::from_ssz_bytes(chunk)) - .collect::, _>>() + .try_fold(Vec::with_capacity(num_items), |mut vec, chunk| { + vec.push(T::from_ssz_bytes(chunk)?); + Ok(vec) + }) .map(Into::into) } else { ssz::decode_list_of_variable_length_items(bytes, Some(max_len)).map(|vec| vec.into())