pub enum Scope {
None,
Local(HashMap<String, Symbol>),
Global(HashMap<String, Symbol>),
}
Expand description
Python uses LEGB scope: Local, Enclosing, Global, and Built-in. Local scope consists of local variables inside a function. Names in the local scope may change new declarations overwrite older ones. Enclosing scope is the scope of a containing function with inner/nested functions. Global is the global scope. Names within the global namespace must be unique. Built-in is basically a special scope for elements that are built into Python.
Variants§
Implementations§
Source§impl Scope
impl Scope
pub fn new_local() -> Self
pub fn new_global() -> Self
pub fn insert(&mut self, key: String, symbol: Symbol) -> Option<Symbol>
pub fn get(&self, key: &str) -> Option<&Symbol>
pub fn contains_key(&self, key: &str) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scope
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnwindSafe for Scope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ErrorContext for Twhere
T: Debug,
impl<T> ErrorContext for Twhere
T: Debug,
Source§fn with_context(&self, operation: &str) -> String
fn with_context(&self, operation: &str) -> String
Generate a standardized error message with context.