New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource unnecessarily clones #233
Comments
I did originally start out with references, but it made it hard to work with the big openapi struct because of borrows happening in many places, and a couple of extra copies didn't feel that worth optimizing for. Besides, you can always just reach into metadata directly if you are concerned about the cost of using That said, you can try changing the trait and seeing how the examples expand. If it's not as bad as I originally felt it was, then we could possibly change it. |
The experiments for this in #311 did leave a lot to be desired in terms of usability (which is primarily why it still clones like it does today). Resurrecting this discussion now as the trait is being proposed to be split into a more foundational one + a user-facing one in #486. This type of split potentially opens up the door to having an alternative trait that does not clone as heavily (one that users can even define themselves, as it's not tied to how kube_runtime or kube uses it). Maybe if there's demand for such a trait, we could even have it in here as an alternate |
The
Meta
helper trait has the following signatures,All of these end up cloning the underlying thing they're returning; none of them need to; they could return
&str
references.In my particular case, I'm iterating through every object of a particular resource type, this results in quite a few allocations that I end up never needing. (I'm just comparing the
name
, for example.)This would be a breaking change, however, since
kube-rs
isn't at 1.0 yet, I thought I'd suggest it.The text was updated successfully, but these errors were encountered: