Skip to main content

MacroResult

Trait MacroResult 

Source
pub trait MacroResult {
    // Required method
    fn into_result(self) -> Result<TokenStream>;

    // Provided method
    fn into_stream(self) -> TokenStream
       where Self: Sized { ... }
}
Expand description

Helper trait describing values which may be returned by macro implementation methods used by this crate’s macros.

Required Methods§

Source

fn into_result(self) -> Result<TokenStream>

Convert this result into a Result for further processing / validation.

Provided Methods§

Source

fn into_stream(self) -> TokenStream
where Self: Sized,

Convert this result into a proc_macro::TokenStream, ready to return from a native proc_macro implementation.

If into_result() would return an Err, this method should instead generate a compile_error! invocation to nicely report the error.

This method is available if synstructure is built with the "proc-macro" feature.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MacroResult for TokenStream

Available on crate feature proc-macro and not (WebAssembly and (target_os=unknown or WASI)) only.
Source§

impl MacroResult for TokenStream

Source§

impl<T: MacroResult> MacroResult for Result<T>

Implementors§