Skip to content

internal: Remove unnecessary CfgFlag definition in project-model #17821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,14 @@ impl Env {
pub fn extend_from_other(&mut self, other: &Env) {
self.entries.extend(other.entries.iter().map(|(x, y)| (x.to_owned(), y.to_owned())));
}

pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}

pub fn insert(&mut self, k: impl Into<String>, v: impl Into<String>) -> Option<String> {
self.entries.insert(k.into(), v.into())
}
}

impl From<Env> for Vec<(String, String)> {
Expand All @@ -700,6 +708,15 @@ impl From<Env> for Vec<(String, String)> {
}
}

impl<'a> IntoIterator for &'a Env {
type Item = (&'a String, &'a String);
type IntoIter = std::collections::hash_map::Iter<'a, String, String>;

fn into_iter(self) -> Self::IntoIter {
self.entries.iter()
}
}

#[derive(Debug)]
pub struct CyclicDependenciesError {
path: Vec<(CrateId, Option<CrateDisplayName>)>,
Expand Down
8 changes: 8 additions & 0 deletions crates/cfg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ impl<'a> IntoIterator for &'a CfgOptions {
}
}

impl FromIterator<CfgAtom> for CfgOptions {
fn from_iter<T: IntoIterator<Item = CfgAtom>>(iter: T) -> Self {
let mut options = CfgOptions::default();
options.extend(iter);
options
}
}

#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct CfgDiff {
// Invariants: No duplicates, no atom that's both in `enable` and `disable`.
Expand Down
Loading