Rename and change add_roots to return a Vec.

This commit is contained in:
David Wood 2019-03-07 00:39:50 +01:00
parent 00d927a188
commit 614dd3c347
No known key found for this signature in database
GPG key ID: 01760B4F9F53F154
3 changed files with 8 additions and 3 deletions

View file

@ -50,20 +50,25 @@ impl ProjectWorkspace {
}
}
pub fn add_roots(&self, roots: &mut Vec<PathBuf>) {
pub fn to_roots(&self) -> Vec<PathBuf> {
match self {
ProjectWorkspace::Json { project } => {
let mut roots = Vec::with_capacity(project.roots.len());
for root in &project.roots {
roots.push(root.path.clone());
}
roots
}
ProjectWorkspace::Cargo { cargo, sysroot } => {
let mut roots =
Vec::with_capacity(cargo.packages().count() + sysroot.crates().count());
for pkg in cargo.packages() {
roots.push(pkg.root(&cargo).to_path_buf());
}
for krate in sysroot.crates() {
roots.push(krate.root_dir(&sysroot).to_path_buf())
}
roots
}
}
}