Trait RenamedVariable

Source
pub trait RenamedVariable:
    Sealed
    + Clone
    + Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn new_private(sym: Atom) -> Self;
    fn to_id(&self) -> Id;
}
Expand description

A trait that is used to represent a renamed variable. For renamer_keep_contexts, the syntax contexts of the replacements should be correct (unique), while for hygiene (which calls renamer), the resulting syntax contexts are irrelevant. This type is used to handle both cases without code duplication by using HashMap<Id, impl RenamedVariable> everywhere:

  • For renamer, HashMap<Id, Atom> is used (and SyntaxContext::empty() isn’t store unnecessarily). All replaced idents have the same SyntaxContext #0.
  • For renamer_keep_contexts, HashMap<Id, Id> is used. All replaced idents have a unique SyntaxContext.

Required Methods§

Source

fn new_private(sym: Atom) -> Self

Potentially create a new private variable, depending on whether the consumer cares about the syntax context after the renaming.

Source

fn to_id(&self) -> Id

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl RenamedVariable for Atom

Source§

fn new_private(sym: Atom) -> Self

Source§

fn to_id(&self) -> Id

Source§

impl RenamedVariable for Id

Source§

fn new_private(sym: Atom) -> Self

Source§

fn to_id(&self) -> Id

Implementors§