Skip to content

Commit 987fb26

Browse files
committed
Migrate to iterators
1 parent b7d5172 commit 987fb26

File tree

1 file changed

+3
-15
lines changed
  • crates/ra_project_model/src

1 file changed

+3
-15
lines changed

crates/ra_project_model/src/lib.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,10 @@ impl ProjectWorkspace {
142142
pub fn out_dirs(&self) -> Vec<PathBuf> {
143143
match self {
144144
ProjectWorkspace::Json { project } => {
145-
let mut out_dirs = Vec::with_capacity(project.crates.len());
146-
for krate in &project.crates {
147-
if let Some(out_dir) = &krate.out_dir {
148-
out_dirs.push(out_dir.to_path_buf());
149-
}
150-
}
151-
out_dirs
145+
project.crates.iter().filter_map(|krate| krate.out_dir.as_ref()).cloned().collect()
152146
}
153-
ProjectWorkspace::Cargo { cargo, sysroot: _sysroot } => {
154-
let mut out_dirs = Vec::with_capacity(cargo.packages().len());
155-
for pkg in cargo.packages() {
156-
if let Some(out_dir) = &cargo[pkg].out_dir {
157-
out_dirs.push(out_dir.to_path_buf());
158-
}
159-
}
160-
out_dirs
147+
ProjectWorkspace::Cargo { cargo, sysroot: _ } => {
148+
cargo.packages().filter_map(|pkg| cargo[pkg].out_dir.as_ref()).cloned().collect()
161149
}
162150
}
163151
}

0 commit comments

Comments
 (0)