dtolnay / quote

Rust quasi-quoting
Apache License 2.0
1.32k stars 90 forks source link

Export struct from quote! #256

Closed Massimiliano-solutiontech closed 1 year ago

Massimiliano-solutiontech commented 1 year ago

Maybe that's a noob question but I can't export a struct created inside a quote! My goal is to use MyStruct outside the crate where the derive is created

let struct_token = quote! {
    pub struct MyStruct {
        pub id: u32,
        pub val: String,
    }
};

let tokens = quote! {
    ...
    #struct_token
    ...
};

TokenStream::from(tokens)
dtolnay commented 1 year ago

Hi @Massimiliano-solutiontech, sorry that no one was able to provide guidance here. If this is still an issue, you could try taking this question to any of the resources shown in https://www.rust-lang.org/community.