[Wrinting Plugins] How bad .clone() is and how to avoid it? #6713
Unanswered
timofei-iatsenko
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is kinda more Rust-generic, or Plugin writing patterns question:
I often face a situation when I have only a reference to some part of AST and trying to create a new nodes which want to own the value, the most common example:
So i've forced to clone the
tagged_tpl
to be able to get non-referenced value. How bad is that? And how to avoid this?How to do pattern matching while still keeping ownership of value.
If I write it like that, I get another error:
The same may happen with Visitor pattern as well, where I always getting a reference to a node in
visit_{expr}
methodBeta Was this translation helpful? Give feedback.
All reactions