I'm trying to implement a syntax extension within a proc macro to implement postfix syntax similar to
.await to make working with a wrapper type,
Tracked<T>, easier. The operation is sort of monadic; if
b are of type
let c = a.op + b.op,
c has type
Tracked<usize>. I'd like this operation to take its operand either by value or reference, whichever is least restrictive and allows the code to compile. This would allow for this to work ergonomically.
One way I could imagine doing that is by implementing a method on two different receivers,
&T. However, without specialization, I don't know how to do something like that. Even with specialization, I'm not sure if this technique would work.
Does anyone have any tips or suggestions on how I might implement this? I'd be happy to share more information on what I'm trying to do, or how I currently handle a variant of this operation, if it helps. Thank you!