pub struct Command { /* private fields */ }
Expand description
Used to invoke the telety-generated macro in a manageable way.
Implementations§
Source§impl Command
impl Command
Sourcepub fn apply(
&'static self,
macro_path: Path,
needle: impl Into<SingleToken>,
haystack: impl ToTokens,
) -> Apply
pub fn apply( &'static self, macro_path: Path, needle: impl Into<SingleToken>, haystack: impl ToTokens, ) -> Apply
Creates a macro invocation to use this command with the telety-generated macro at macro_path
.
The output of the command will be inserted into haystack
at each instance of needle
.
macro_path
must point to a valid telety-generated macro, otherwise a compile error will occur.
To support future Commands, args
are passed to the command invocation, but they are not currently used.
§Example
ⓘ
#[proc_macro]
pub fn my_public_macro(tokens: TokenStream) -> TokenStream {
// ...
let my_needle: TokenTree = format_ident!("__my_needle__").into();
v1::UNIQUE_IDENT.apply(
&parse_quote!(crate::MyTeletyObj),
&my_needle,
quote! {
my_crate::my_macro_implementation!(#my_needle);
},
None,
)
}
#[doc(hidden)]
#[proc_macro]
pub fn my_macro_implementation(tokens: TokenStream) -> TokenStream {
let ident: Ident = parse2(tokens);
// ...
}
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
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