Struct Scope

Source
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<T: Clone> Clone for Scope<T>

Source§

fn clone(&self) -> Scope<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Scope<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Scope<T>

Source§

fn default() -> Scope<T>

Returns the “default value” for a type. Read more
Source§

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>

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>

Retrieves the value for a particular identifier, if exists.
Source§

impl<T: PartialEq> PartialEq for Scope<T>

Source§

fn eq(&self, other: &Scope<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Sym: Clone, Tbl> SymbolStore<Sym> for Scope<Tbl>
where Tbl: SymbolTable<Sym>,

Source§

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>

Resolves a symbol in this symbol store, or None if no symbol exists for the identifier.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<A> AnnotationType for A
where A: Default + Debug + Clone + PartialEq,