optargs icon indicating copy to clipboard operation
optargs copied to clipboard

Add an `OptStructArc` variant to wrap constructed structs in `Arc`

Open ZhennanWu opened this issue 2 years ago • 0 comments

(This is a proof-of-concept PR in case anyone is also interested in this functionality)

While using this incredible crate, I encountered a usage pattern where the constructed results almost 100% go inside an Arc, and the code would be much much more nicer if the macro would just produce Arc<T> instead of T. So I went ahead and added OptStructArc variant derive macro.

While in theory, we should be able generalize this to any smart pointer, or even any "post-build processing", I found my proc macro skill to be the limiting factor. Hence this solution is a makeshift one. Nevertheless, this PR does not simply duplicate stuff and it would be quite easy to extend other smart pointer variant on top of this work.

MSRV impact: used RPIT syntax which requires Rust >=1.26

ZhennanWu avatar Nov 23 '23 23:11 ZhennanWu