Skip to main content

Transformer

Trait Transformer 

Source
pub trait Transformer: Any {
    // Required method
    fn transform(
        &mut self,
        input: TokenStream,
        argument: TokenStream,
    ) -> Result<TokenStream>;
}
Expand description

A transformer in a pipeline.

A transformer takes a fully resolved TokenStream from the preceding step in an expansion block and mutates it into a new TokenStream.

Implementors of this trait define the behavior of individual operations (e.g., :case, :concatenate, :reverse) in a Pipeline. Transformers can maintain internal state, allowing for complex, stateful token generation across a session.

Required Methods§

Source

fn transform( &mut self, input: TokenStream, argument: TokenStream, ) -> Result<TokenStream>

Transforms an input token stream into an output one.

It receives the input tokens and the raw argument token stream, returning the modified tokens or a syn::Error if the transformation is invalid.

§Errors

The failure mode of this associated function is implementation-dependent.

Implementors§

Source§

impl<T> Transformer for T
where T: Pass + Any,

A blanket implementation for Transformer for all Pass implementors.