Skip to content

Commit 7ce4203

Browse files
committed
Return impl Iterator instead of Vec
1 parent 3c01125 commit 7ce4203

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/config.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,14 @@ impl Cfg {
364364
Toolchain::from(self, name)
365365
}
366366

367-
pub fn get_toolchains_from_regex(&self, regex: Regex) -> Result<Vec<Toolchain<'_>>> {
367+
pub fn get_toolchains_from_regex(
368+
&self,
369+
regex: Regex,
370+
) -> Result<impl Iterator<Item = Toolchain<'_>>> {
368371
Ok(self
369372
.list_toolchains_iter()?
370-
.filter(|toolchain| regex.is_match(toolchain))
371-
.map(|toolchain| Toolchain::from(self, &toolchain).unwrap())
372-
.collect())
373+
.filter(move |toolchain| regex.is_match(toolchain))
374+
.map(move |toolchain| Toolchain::from(self, &toolchain).unwrap()))
373375
}
374376

375377
pub fn verify_toolchain(&self, name: &str) -> Result<Toolchain<'_>> {

0 commit comments

Comments
 (0)