Hacker News new | ask | show | jobs
by imor80 833 days ago
Copy and Clone traits have different semantics. Copy is only for bitwise (and cheap) copies. Clone is for explicit, potentially expensive copies. Also what entails cloning differs from type to type. String, for example, needs to duplicate the pointed to string buffer in the heap, while Arc only increments a reference count.
1 comments

Yes, I know. But in the context of what’s being described here someone getting started with Rust and wanting to avoid issues with lifetimes could very easily be using copy in the way the OP described clone.