From 1d71f92ee6e9d436b96cfda57b886adc4e8a6492 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Tue, 7 Jun 2022 12:10:05 +1000 Subject: [PATCH] Impl `IntoIterator` for `&Targets` Signed-off-by: Jiahao XU --- src/target.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/target.rs b/src/target.rs index 6c8d9f09..2bd52a6e 100644 --- a/src/target.rs +++ b/src/target.rs @@ -3,6 +3,7 @@ use std::io::{BufRead, Cursor}; use std::iter::IntoIterator; use std::ops::Deref; use std::process::Output; +use std::slice; use tokio::process::Command; /// Compiled target triple, used as default for binary fetching @@ -44,6 +45,15 @@ impl IntoIterator for Targets { } } +impl<'a> IntoIterator for &'a Targets { + type Item = &'a Box; + type IntoIter = slice::Iter<'a, Box>; + + fn into_iter(self) -> Self::IntoIter { + (&self.0).into_iter() + } +} + /// Detect the targets supported at runtime, /// which might be different from `TARGET` which is detected /// at compile-time.