Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
xena
5y ago
0 comments
Share
Doesn't the compiler optimize out clones when it can?
0 comments
default
newest
oldest
toby
5y ago
There's a Cargo tool called "clippy" which will tell you if it finds unnecessary clones.
tylerhou
5y ago
Probably not; detecting unnecessary clones is expensive for non-trivial cases. If a human can't prove that the clone isn't necessary (by writing the code in such a manner that the borrow checker accepts), I doubt the compiler could.
sanxiyn
5y ago
No, not really.
j
/
k
navigate · click thread line to collapse