File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -181,22 +181,16 @@ impl<'de, const N: usize> Visitor<'de> for ByteArrayVisitor<N> {
181181 write ! ( formatter, "a byte array of length {}" , N )
182182 }
183183
184- fn visit_seq < V > ( self , mut visitor : V ) -> Result < ByteArray < N > , V :: Error >
184+ fn visit_seq < V > ( self , mut seq : V ) -> Result < ByteArray < N > , V :: Error >
185185 where
186186 V : SeqAccess < ' de > ,
187187 {
188188 let mut bytes = [ 0 ; N ] ;
189- let mut idx = 0 ;
190- while let Some ( b) = visitor. next_element ( ) ? {
191- bytes[ idx] = b;
192- idx += 1 ;
193- if idx == N {
194- break ;
195- }
196- }
197189
198- if idx != N {
199- return Err ( V :: Error :: invalid_length ( N , & self ) ) ;
190+ for ( idx, byte) in bytes. iter_mut ( ) . enumerate ( ) {
191+ * byte = seq
192+ . next_element ( ) ?
193+ . ok_or_else ( || V :: Error :: invalid_length ( idx, & self ) ) ?;
200194 }
201195
202196 Ok ( ByteArray :: from ( bytes) )
You can’t perform that action at this time.
0 commit comments