From 987fb26a5b9bb2c4352b688cfa20e0fcc8506216 Mon Sep 17 00:00:00 2001 From: veetaha Date: Wed, 1 Apr 2020 02:52:44 +0300 Subject: Migrate to iterators --- crates/ra_project_model/src/lib.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'crates/ra_project_model') diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index a133243b4..950db71ec 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -142,22 +142,10 @@ impl ProjectWorkspace { pub fn out_dirs(&self) -> Vec { match self { ProjectWorkspace::Json { project } => { - let mut out_dirs = Vec::with_capacity(project.crates.len()); - for krate in &project.crates { - if let Some(out_dir) = &krate.out_dir { - out_dirs.push(out_dir.to_path_buf()); - } - } - out_dirs + project.crates.iter().filter_map(|krate| krate.out_dir.as_ref()).cloned().collect() } - ProjectWorkspace::Cargo { cargo, sysroot: _sysroot } => { - let mut out_dirs = Vec::with_capacity(cargo.packages().len()); - for pkg in cargo.packages() { - if let Some(out_dir) = &cargo[pkg].out_dir { - out_dirs.push(out_dir.to_path_buf()); - } - } - out_dirs + ProjectWorkspace::Cargo { cargo, sysroot: _ } => { + cargo.packages().filter_map(|pkg| cargo[pkg].out_dir.as_ref()).cloned().collect() } } } -- cgit v1.2.3