pub struct MacroExpander {
pub dispatcher: MacroDispatcher,
/* private fields */
}Expand description
Core macro expansion engine
This struct provides the expansion logic that can be reused by any macro package. Each macro package creates its own instance, which will use that package’s local inventory of macros.
Fields§
§dispatcher: MacroDispatcherImplementations§
Source§impl MacroExpander
impl MacroExpander
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new expander with the local registry populated from inventory
Sourcepub fn new_with_env(_env: Option<&Env>) -> Result<Self>
pub fn new_with_env(_env: Option<&Env>) -> Result<Self>
Create a new expander, optionally with a NAPI environment
Sourcepub fn with_config(config: MacroConfig, root_dir: PathBuf) -> Result<Self>
pub fn with_config(config: MacroConfig, root_dir: PathBuf) -> Result<Self>
Create an expander with a specific config
Sourcepub fn with_config_and_env(
config: MacroConfig,
root_dir: PathBuf,
_env: Option<&Env>,
) -> Result<Self>
pub fn with_config_and_env( config: MacroConfig, root_dir: PathBuf, _env: Option<&Env>, ) -> Result<Self>
Create an expander with a specific config and optional NAPI environment
Sourcepub fn set_keep_decorators(&mut self, keep: bool)
pub fn set_keep_decorators(&mut self, keep: bool)
Control whether decorators are preserved in the expanded output.
Sourcepub fn expand_source(
&self,
source: &str,
file_name: &str,
) -> Result<MacroExpansion>
pub fn expand_source( &self, source: &str, file_name: &str, ) -> Result<MacroExpansion>
Expand all macros in the source code (simple API for CLI usage)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MacroExpander
impl !RefUnwindSafe for MacroExpander
impl Send for MacroExpander
impl Sync for MacroExpander
impl Unpin for MacroExpander
impl !UnwindSafe for MacroExpander
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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