Trait RenamedVariable
pub trait RenamedVariable:
Sized
+ Sealed
+ Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn new_private(sym: Atom) -> Self;
fn to_id(&self) -> (Atom, SyntaxContext);
}
Available on crate feature
__ecma
and (crate features __ecma_transforms
or __testing_transform
) only.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 (andSyntaxContext::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§
fn new_private(sym: Atom) -> Self
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.
fn to_id(&self) -> (Atom, SyntaxContext)
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.