pub struct VarTable<'a> { /* private fields */ }
Expand description
Table for keeping track of node parameters.
Variables refer to the parameters of a node which introduces a symbol. Variables have an associated name and are scoped via nodes. The types of parameters of a node may only refer to earlier parameters in the same node in the order they are defined. A variable name must be unique within a single node. Each node that introduces a symbol introduces a new isolated scope for variables.
§Examples
let mut vars = VarTable::new();
vars.enter(NodeId(0));
vars.insert("foo").unwrap();
assert_eq!(vars.resolve("foo").unwrap(), VarId(NodeId(0), 0));
assert!(!vars.is_visible(VarId(NodeId(0), 1)));
vars.insert("bar").unwrap();
assert!(vars.is_visible(VarId(NodeId(0), 1)));
assert_eq!(vars.resolve("bar").unwrap(), VarId(NodeId(0), 1));
vars.enter(NodeId(1));
assert!(vars.resolve("foo").is_err());
assert!(!vars.is_visible(VarId(NodeId(0), 0)));
vars.exit();
assert_eq!(vars.resolve("foo").unwrap(), VarId(NodeId(0), 0));
assert!(vars.is_visible(VarId(NodeId(0), 0)));
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for VarTable<'a>
impl<'a> RefUnwindSafe for VarTable<'a>
impl<'a> Send for VarTable<'a>
impl<'a> Sync for VarTable<'a>
impl<'a> Unpin for VarTable<'a>
impl<'a> UnwindSafe for VarTable<'a>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more