scoped_stack
scoped_stack is a Rust library that provides a stack that can be scoped. Each ScopedStack
has a HashMap
of values and a child ScopedStack
. When a scope is pushed, a new ScopedStack
is created with the uppermost ScopedStack
as its parent. When a scope is popped, the uppermost ScopedStack
is removed. When a value is pushed, it is added to the uppermost ScopedStack
. When a value is popped, it is removed from the uppermost ScopedStack
with that key. When a value is looked up, the value from the uppermost ScopedStack
with that key is returned.
Example
use ScopedStack;
let mut stack = new;
stack.insert;
stack.insert;
stack.insert;
assert_eq!;
assert_eq!;
assert_eq!;
stack.push_scope;
stack.insert;
stack.insert;
assert_eq!;
assert_eq!;
assert_eq!;
stack.pop_scope;
assert_eq!;
assert_eq!;
assert_eq!;