diff options
author | David Tolnay <dtolnay@chromium.org> | 2019-04-15 16:58:42 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-18 19:51:01 -0700 |
commit | dc4effa72b214bc3bd14ca2f7772ab1b728aef5b (patch) | |
tree | 61c308a8c165a6fbe65f947da4abd241a9dd265d /sys_util/src/write_zeroes.rs | |
parent | 64cd5eae5778b86f6e498a6fa1b1962693aa5a46 (diff) | |
download | crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.tar crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.tar.gz crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.tar.bz2 crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.tar.lz crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.tar.xz crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.tar.zst crosvm-dc4effa72b214bc3bd14ca2f7772ab1b728aef5b.zip |
clippy: Iterate without calling .iter()
See: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop https://rust-lang.github.io/rust-clippy/master/index.html#explicit_into_iter_loop Before: for element in slice.iter() {...} After: for element in slice {...} TEST=grep -r '\.iter() {' TEST=grep -r '\.iter_mut() {' TEST=grep -r '\.into_iter() {' TEST=cargo check --all-features TEST=local kokoro Change-Id: I27f0df7cfa1064b2c8b162cba263513926a433a9 Reviewed-on: https://chromium-review.googlesource.com/1568525 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'sys_util/src/write_zeroes.rs')
-rw-r--r-- | sys_util/src/write_zeroes.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys_util/src/write_zeroes.rs b/sys_util/src/write_zeroes.rs index 8c7f775..51f0dbe 100644 --- a/sys_util/src/write_zeroes.rs +++ b/sys_util/src/write_zeroes.rs @@ -86,15 +86,15 @@ mod tests { f.seek(SeekFrom::Start(0)).unwrap(); f.read(&mut readback).unwrap(); // Bytes before the write should still be 0 - for read in readback[0..1234].iter() { + for read in &readback[0..1234] { assert_eq!(*read, 0); } // Bytes that were just written should be 0x55 - for read in readback[1234..(1234 + 5678)].iter() { + for read in &readback[1234..(1234 + 5678)] { assert_eq!(*read, 0x55); } // Bytes after the written area should still be 0 - for read in readback[(1234 + 5678)..].iter() { + for read in &readback[(1234 + 5678)..] { assert_eq!(*read, 0); } @@ -108,23 +108,23 @@ mod tests { f.seek(SeekFrom::Start(0)).unwrap(); f.read(&mut readback).unwrap(); // Bytes before the write should still be 0 - for read in readback[0..1234].iter() { + for read in &readback[0..1234] { assert_eq!(*read, 0); } // Original data should still exist before the write_zeroes region - for read in readback[1234..2345].iter() { + for read in &readback[1234..2345] { assert_eq!(*read, 0x55); } // The write_zeroes region should now be zero - for read in readback[2345..(2345 + 4321)].iter() { + for read in &readback[2345..(2345 + 4321)] { assert_eq!(*read, 0); } // Original data should still exist after the write_zeroes region - for read in readback[(2345 + 4321)..(1234 + 5678)].iter() { + for read in &readback[(2345 + 4321)..(1234 + 5678)] { assert_eq!(*read, 0x55); } // The rest of the file should still be 0 - for read in readback[(1234 + 5678)..].iter() { + for read in &readback[(1234 + 5678)..] { assert_eq!(*read, 0); } } @@ -158,11 +158,11 @@ mod tests { f.seek(SeekFrom::Start(0)).unwrap(); f.read(&mut readback).unwrap(); // The write_zeroes region should now be zero - for read in readback[0..0x10001].iter() { + for read in &readback[0..0x10001] { assert_eq!(*read, 0); } // Original data should still exist after the write_zeroes region - for read in readback[0x10001..0x20000].iter() { + for read in &readback[0x10001..0x20000] { assert_eq!(*read, 0x55); } } |