mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Rename and change add_roots
to return a Vec
.
This commit is contained in:
parent
00d927a188
commit
614dd3c347
3 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue