Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/project-model/src/cargo_workspace.rs')
-rw-r--r--crates/project-model/src/cargo_workspace.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs
index e3fdeb448d..649a149504 100644
--- a/crates/project-model/src/cargo_workspace.rs
+++ b/crates/project-model/src/cargo_workspace.rs
@@ -10,7 +10,7 @@ use base_db::Edition;
use cargo_metadata::{CargoOpt, MetadataCommand};
use la_arena::{Arena, Idx};
use paths::{AbsPath, AbsPathBuf};
-use rustc_hash::FxHashMap;
+use rustc_hash::{FxHashMap, FxHashSet};
use serde::Deserialize;
use serde_json::from_value;
@@ -491,6 +491,21 @@ impl CargoWorkspace {
None
}
+ /// Returns the union of the features of all member crates in this workspace.
+ pub fn workspace_features(&self) -> FxHashSet<String> {
+ self.packages()
+ .filter_map(|package| {
+ let package = &self[package];
+ if package.is_member {
+ Some(package.features.keys().cloned())
+ } else {
+ None
+ }
+ })
+ .flatten()
+ .collect()
+ }
+
fn is_unique(&self, name: &str) -> bool {
self.packages.iter().filter(|(_, v)| v.name == name).count() == 1
}