Selectively borrowing macro input

Hey all,

I've been building a DSL, and part of it involves a macro that ingests a wrapped value, performs some operations, and provides access to the type within the wrapper (internally returning a public field). Calling it might look like this:

let val2 = my_macro!(my_macro!(val1.field1).method1());

The issue I've been running into is that, when I create a block within the macro and return the unwrapped value field, I must explicitly decide whether v1.field1 is being borrowed, borrowed mutably, or moved. However, I'd like that to be inferred, just like in the expression v1.field1.method1(), v1.field1 is borrowed or moved depending on the receiver type of method1. Is there some trick or technique I can use to achieve this?

If you need more information, like exactly what my wrapped type is or what I'm trying to achieve, I'd be happy to provide that.

Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.