From da4c792d8094f35c05c41c9aeb5dfe4aa67ca1ac Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Tue, 30 Nov 2021 14:03:32 -0500 Subject: add an assert and remove an iter_mut in reference_impl Suggested in https://github.com/rust-lang/rust-clippy/issues/8039. --- reference_impl/reference_impl.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'reference_impl/reference_impl.rs') diff --git a/reference_impl/reference_impl.rs b/reference_impl/reference_impl.rs index e669f36..83ac795 100644 --- a/reference_impl/reference_impl.rs +++ b/reference_impl/reference_impl.rs @@ -125,8 +125,9 @@ fn first_8_words(compression_output: [u32; 16]) -> [u32; 8] { } fn words_from_little_endian_bytes(bytes: &[u8], words: &mut [u32]) { - for (bytes_block, word) in bytes.chunks_exact(4).zip(words.iter_mut()) { - *word = u32::from_le_bytes(bytes_block.try_into().unwrap()); + debug_assert_eq!(bytes.len(), 4 * words.len()); + for (four_bytes, word) in bytes.chunks_exact(4).zip(words) { + *word = u32::from_le_bytes(four_bytes.try_into().unwrap()); } } -- cgit v1.2.3