File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed
Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -304,18 +304,19 @@ where
304304 ) ) ) ;
305305 }
306306
307- bytes
308- . chunks ( T :: ssz_fixed_len ( ) )
309- . map ( |chunk| T :: from_ssz_bytes ( chunk) )
310- . collect :: < Result < Vec < T > , _ > > ( )
311- . and_then ( |vec| {
312- Self :: new ( vec) . map_err ( |e| {
313- ssz:: DecodeError :: BytesInvalid ( format ! (
314- "Wrong number of FixedVector elements: {:?}" ,
315- e
316- ) )
317- } )
318- } )
307+ let vec = bytes. chunks ( T :: ssz_fixed_len ( ) ) . try_fold (
308+ Vec :: with_capacity ( num_items) ,
309+ |mut vec, chunk| {
310+ vec. push ( T :: from_ssz_bytes ( chunk) ?) ;
311+ Ok ( vec)
312+ } ,
313+ ) ?;
314+ Self :: new ( vec) . map_err ( |e| {
315+ ssz:: DecodeError :: BytesInvalid ( format ! (
316+ "Wrong number of FixedVector elements: {:?}" ,
317+ e
318+ ) )
319+ } )
319320 } else {
320321 let vec = ssz:: decode_list_of_variable_length_items ( bytes, Some ( fixed_len) ) ?;
321322 Self :: new ( vec) . map_err ( |e| {
You can’t perform that action at this time.
0 commit comments