pub trait TryToTokens {
// Required method
fn try_to_tokens(&self, tokens: &mut TokenStream) -> Result<(), Diagnostic>;
// Provided method
fn try_to_token_stream(&self) -> Result<TokenStream, Diagnostic> { ... }
}
Expand description
A trait for converting AST structs into Tokens and adding them to a TokenStream, or providing a diagnostic if conversion fails.
Required Methods§
sourcefn try_to_tokens(&self, tokens: &mut TokenStream) -> Result<(), Diagnostic>
fn try_to_tokens(&self, tokens: &mut TokenStream) -> Result<(), Diagnostic>
Attempt to convert a Self
into tokens and add it to the TokenStream
Provided Methods§
sourcefn try_to_token_stream(&self) -> Result<TokenStream, Diagnostic>
fn try_to_token_stream(&self) -> Result<TokenStream, Diagnostic>
Attempt to convert a Self
into a new TokenStream