pub struct ScopeSet(/* private fields */);Expand description
A set of hygiene scopes, kept sorted and deduplicated so that subset tests are a merge.
The empty set is the source program’s own scope, which is why an ordinary top-level definition
is visible everywhere: {} ⊆ S for every S.
Implementations§
Source§impl ScopeSet
impl ScopeSet
pub fn empty() -> ScopeSet
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn contains(&self, s: Scope) -> bool
pub fn insert(&self, s: Scope) -> ScopeSet
pub fn remove(&self, s: Scope) -> ScopeSet
Sourcepub fn flip(&self, s: Scope) -> ScopeSet
pub fn flip(&self, s: Scope) -> ScopeSet
Add the scope if absent, remove it if present.
This is the operation that makes hygiene work: the expander adds a fresh scope to a macro’s input and flips it on the output, so identifiers that came from the call site come back to their original scopes while identifiers the template introduced acquire the new one.
Sourcepub fn is_subset_of(&self, other: &ScopeSet) -> bool
pub fn is_subset_of(&self, other: &ScopeSet) -> bool
self ⊆ other. A binding is a candidate for a reference exactly when this holds.
Trait Implementations§
Source§impl Ord for ScopeSet
impl Ord for ScopeSet
Source§impl PartialOrd for ScopeSet
impl PartialOrd for ScopeSet
impl Eq for ScopeSet
impl StructuralPartialEq for ScopeSet
Auto Trait Implementations§
impl Freeze for ScopeSet
impl RefUnwindSafe for ScopeSet
impl Send for ScopeSet
impl Sync for ScopeSet
impl Unpin for ScopeSet
impl UnwindSafe for ScopeSet
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