Fixing lint warnings

This commit is contained in:
Stephen Chung
2020-03-24 16:57:35 +08:00
parent 3ea482567f
commit d21f66b911
13 changed files with 87 additions and 76 deletions

View File

@@ -77,6 +77,11 @@ impl<'a> Scope<'a> {
self.0.len()
}
/// Is the Scope empty?
pub fn is_empty(&self) -> bool {
self.0.len() == 0
}
/// Add (push) a new variable to the Scope.
pub fn push<K: Into<Cow<'a, str>>, T: Any + Clone>(&mut self, name: K, value: T) {
let value = value.into_dynamic();
@@ -152,8 +157,7 @@ impl<'a> Scope<'a> {
.iter()
.enumerate()
.rev() // Always search a Scope in reverse order
.find(|(_, ScopeEntry { name, .. })| name == key)
.is_some()
.any(|(_, ScopeEntry { name, .. })| name == key)
}
/// Find a variable in the Scope, starting from the last.
@@ -224,6 +228,12 @@ impl<'a> Scope<'a> {
}
}
impl Default for Scope<'_> {
fn default() -> Self {
Scope::new()
}
}
impl<'a, K> iter::Extend<(K, VariableType, Dynamic)> for Scope<'a>
where
K: Into<Cow<'a, str>>,