summary refs log tree commit diff
path: root/sys_util/src/poll.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-15 16:58:42 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-18 19:51:01 -0700
commitdc4effa72b214bc3bd14ca2f7772ab1b728aef5b (patch)
tree61c308a8c165a6fbe65f947da4abd241a9dd265d /sys_util/src/poll.rs
parent64cd5eae5778b86f6e498a6fa1b1962693aa5a46 (diff)
downloadcrosvm-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/poll.rs')
-rw-r--r--sys_util/src/poll.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys_util/src/poll.rs b/sys_util/src/poll.rs
index 2f15198..0da0831 100644
--- a/sys_util/src/poll.rs
+++ b/sys_util/src/poll.rs
@@ -211,6 +211,15 @@ impl<'a, T: PollToken> PollEvents<'a, T> {
     }
 }
 
+impl<'a, T: PollToken> IntoIterator for &'a PollEvents<'_, T> {
+    type Item = PollEvent<'a, T>;
+    type IntoIter = PollEventIter<'a, slice::Iter<'a, epoll_event>, T>;
+
+    fn into_iter(self) -> Self::IntoIter {
+        self.iter()
+    }
+}
+
 /// A deep copy of the event records from `PollEvents`.
 pub struct PollEventsOwned<T> {
     count: usize,