summaryrefslogtreecommitdiffstats
path: root/third_party/rust/headers/src/util/iter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/headers/src/util/iter.rs')
-rw-r--r--third_party/rust/headers/src/util/iter.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/third_party/rust/headers/src/util/iter.rs b/third_party/rust/headers/src/util/iter.rs
new file mode 100644
index 0000000000..03ed691ed6
--- /dev/null
+++ b/third_party/rust/headers/src/util/iter.rs
@@ -0,0 +1,11 @@
+pub trait IterExt: Iterator {
+ fn just_one(&mut self) -> Option<Self::Item> {
+ let one = self.next()?;
+ match self.next() {
+ Some(_) => None,
+ None => Some(one),
+ }
+ }
+}
+
+impl<T: Iterator> IterExt for T {}