Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/base-db/src/input.rs')
-rw-r--r--crates/base-db/src/input.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index 460581f4a6..3616fa9fd8 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -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)> {
@@ -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>)>,