pub struct Expander { /* private fields */ }
Expand description
Expander to replace a tokenstream by a include to a file
Implementations§
source§impl Expander
impl Expander
sourcepub fn new(filename_base: impl AsRef<str>) -> Self
pub fn new(filename_base: impl AsRef<str>) -> Self
Create a new expander.
The filename_base
will be expanded to {filename_base}-{digest}.rs
in order to dismabiguate
.
sourcepub fn add_comment(self, comment: impl Into<Option<String>>) -> Self
pub fn add_comment(self, comment: impl Into<Option<String>>) -> Self
Add a header comment.
sourcepub fn fmt(self, edition: impl Into<Edition>) -> Self
pub fn fmt(self, edition: impl Into<Edition>) -> Self
Format the resulting file, for readability.
sourcepub fn fmt_full(
self,
channel: impl Into<Channel>,
edition: impl Into<Edition>,
allow_failure: bool,
) -> Self
pub fn fmt_full( self, channel: impl Into<Channel>, edition: impl Into<Edition>, allow_failure: bool, ) -> Self
Format the resulting file, for readability.
Allows to specify channel
and if a failure is fatal in addition.
Note: Calling [fn fmt(..)
] afterwards will override settings given.
sourcepub fn verbose(self, verbose: bool) -> Self
pub fn verbose(self, verbose: bool) -> Self
Print the path of the generated file to stderr
during the proc-macro invocation.
sourcepub fn maybe_write_to_out_dir(
self,
tokens: impl Into<Result<TokenStream, Error>>,
) -> Result<Result<TokenStream>, Error>
pub fn maybe_write_to_out_dir( self, tokens: impl Into<Result<TokenStream, Error>>, ) -> Result<Result<TokenStream>, Error>
Create a file with filename
under env!("OUT_DIR")
if it’s not an Err(_)
.
sourcepub fn write_to_out_dir(self, tokens: TokenStream) -> Result<TokenStream, Error>
pub fn write_to_out_dir(self, tokens: TokenStream) -> Result<TokenStream, Error>
Create a file with filename
under env!("OUT_DIR")
.
sourcepub fn maybe_write_to(
self,
maybe_tokens: impl Into<Result<TokenStream, Error>>,
dest_dir: &Path,
) -> Result<Result<TokenStream>, Error>
pub fn maybe_write_to( self, maybe_tokens: impl Into<Result<TokenStream, Error>>, dest_dir: &Path, ) -> Result<Result<TokenStream>, Error>
Create a file with filename
at dest
if it’s not an Err(_)
.
sourcepub fn write_to(
self,
tokens: TokenStream,
dest_dir: &Path,
) -> Result<TokenStream, Error>
pub fn write_to( self, tokens: TokenStream, dest_dir: &Path, ) -> Result<TokenStream, Error>
Create a file with self.filename
in dest_dir
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Expander
impl RefUnwindSafe for Expander
impl Send for Expander
impl Sync for Expander
impl Unpin for Expander
impl UnwindSafe for Expander
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