Skip to content

Commit 4523657

Browse files
committed
Auto merge of #17821 - Veykril:project-model-cleanup, r=Veykril
internal: Remove unnecessary CfgFlag definition in project-model
2 parents 0c20faf + ffd28e6 commit 4523657

File tree

9 files changed

+317
-323
lines changed

9 files changed

+317
-323
lines changed

crates/base-db/src/input.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,14 @@ impl Env {
690690
pub fn extend_from_other(&mut self, other: &Env) {
691691
self.entries.extend(other.entries.iter().map(|(x, y)| (x.to_owned(), y.to_owned())));
692692
}
693+
694+
pub fn is_empty(&self) -> bool {
695+
self.entries.is_empty()
696+
}
697+
698+
pub fn insert(&mut self, k: impl Into<String>, v: impl Into<String>) -> Option<String> {
699+
self.entries.insert(k.into(), v.into())
700+
}
693701
}
694702

695703
impl From<Env> for Vec<(String, String)> {
@@ -700,6 +708,15 @@ impl From<Env> for Vec<(String, String)> {
700708
}
701709
}
702710

711+
impl<'a> IntoIterator for &'a Env {
712+
type Item = (&'a String, &'a String);
713+
type IntoIter = std::collections::hash_map::Iter<'a, String, String>;
714+
715+
fn into_iter(self) -> Self::IntoIter {
716+
self.entries.iter()
717+
}
718+
}
719+
703720
#[derive(Debug)]
704721
pub struct CyclicDependenciesError {
705722
path: Vec<(CrateId, Option<CrateDisplayName>)>,

crates/cfg/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ impl<'a> IntoIterator for &'a CfgOptions {
108108
}
109109
}
110110

111+
impl FromIterator<CfgAtom> for CfgOptions {
112+
fn from_iter<T: IntoIterator<Item = CfgAtom>>(iter: T) -> Self {
113+
let mut options = CfgOptions::default();
114+
options.extend(iter);
115+
options
116+
}
117+
}
118+
111119
#[derive(Default, Clone, Debug, PartialEq, Eq)]
112120
pub struct CfgDiff {
113121
// Invariants: No duplicates, no atom that's both in `enable` and `disable`.

0 commit comments

Comments
 (0)