the light is getting closer
This commit is contained in:
@@ -4,7 +4,7 @@ pub struct NameStack<T>(Vec<HashMap<String, T>>);
|
||||
|
||||
impl<T> NameStack<T> {
|
||||
pub fn new() -> Self {
|
||||
Self(Vec::new())
|
||||
Self(vec![HashMap::new()])
|
||||
}
|
||||
pub fn search(&self, name: &str) -> Option<&T> {
|
||||
for level in self.0.iter().rev() {
|
||||
@@ -14,4 +14,10 @@ impl<T> NameStack<T> {
|
||||
}
|
||||
None
|
||||
}
|
||||
pub fn push(&mut self) {
|
||||
self.0.push(HashMap::new());
|
||||
}
|
||||
pub fn pop(&mut self) {
|
||||
self.0.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user