#Dumb Macro Question

9 messages · Page 1 of 1 (latest)

silk zephyr
#

Hello, I have a macro I'm putting on an Impl block that takes methods in the block and generates message structs for them:

#[make_messages]
impl Foo {
   fn test(&self, num: usize)
}

Outputs:

struct FooTestMessage(usize);

Ignoring the fact that I could do this per method instead of over the whole impl block, I'm hitting an issue: the impl block is being consumed and I can't figure out how to write it back properly.

I've attempted to clone the token stream of the block and extend it with my new struct definitions, but it ends up outputting impl Foo {} without any of the methods in the block.

Thanks in advance for any help!

silk zephyr
#

Even just outputting the input directly also leads to the empty impl block

#

And cloning the syn::Block and returning that also returns an empty impl...

sudden ermine
#

extending the token stream should work

#

post your macro code?

sharp tide
#

are you returning the attr TokenStream, or the item TokenStream?

silk zephyr
#

The item TokenStream

silk zephyr
#

Oh shit wait