pub struct Scope<T> {
pub item: T,
pub parent: Option<Rc<RefCell<Scope<T>>>>,
}
Expand description
General scope object with underlying data structure T
.
Scoping is handled by a linked list of Scope
objects from the child Scope
object (which is
the parent of no other scope) to the root (global) Scope
object, which has no parent.
Fields§
§item: T
Underlying scoped data structure.
parent: Option<Rc<RefCell<Scope<T>>>>
Optional pointer to the parent of this scope.
This should be Some(...)
for every Scope
object except the root node.
This is maintained as an Rc<RefCell<...>>
since a single scope can be the parent of
multiple other scopes.
Trait Implementations§
Source§impl<Val: Clone, T> MemoryStore<Val> for Scope<T>where
T: MemoryTable<Val>,
impl<Val: Clone, T> MemoryStore<Val> for Scope<T>where
T: MemoryTable<Val>,
Source§fn set(&mut self, ident: Identifier, value: Val) -> Result<Option<Val>, String>
fn set(&mut self, ident: Identifier, value: Val) -> Result<Option<Val>, String>
Sets (or updates) the value in memory for an identifier. Returns the previous value (if
exists). Typically, the identifier should already exist in the store, but may not have
an existing value. Read more
Source§fn get(&self, ident: &Identifier) -> Option<Val>
fn get(&self, ident: &Identifier) -> Option<Val>
Retrieves the value for a particular identifier, if exists.
Source§impl<Sym: Clone, Tbl> SymbolStore<Sym> for Scope<Tbl>where
Tbl: SymbolTable<Sym>,
impl<Sym: Clone, Tbl> SymbolStore<Sym> for Scope<Tbl>where
Tbl: SymbolTable<Sym>,
Source§fn define(&mut self, ident: Identifier, symbol: Sym) -> Option<Sym>
fn define(&mut self, ident: Identifier, symbol: Sym) -> Option<Sym>
Defines (or updates) a symbol in this symbol store. Returns previous symbol if this
identifier has been previously declared.
Source§fn resolve(&self, ident: &Identifier) -> Option<Sym>
fn resolve(&self, ident: &Identifier) -> Option<Sym>
Resolves a symbol in this symbol store, or
None
if no symbol exists for the identifier.impl<T> StructuralPartialEq for Scope<T>
Auto Trait Implementations§
impl<T> Freeze for Scope<T>where
T: Freeze,
impl<T> !RefUnwindSafe for Scope<T>
impl<T> !Send for Scope<T>
impl<T> !Sync for Scope<T>
impl<T> Unpin for Scope<T>where
T: Unpin,
impl<T> !UnwindSafe for Scope<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more