Comment by sshine
1 year ago
> `Clone` is not zero cost, should we throw that out too?
Am I mistaken when I say that `ToOwned` is sometimes zero-cost?
And that `.to_owned()` vs. `.clone()` is free when the trait instances allow it?
1 year ago
> `Clone` is not zero cost, should we throw that out too?
Am I mistaken when I say that `ToOwned` is sometimes zero-cost?
And that `.to_owned()` vs. `.clone()` is free when the trait instances allow it?
Both _can_ be free but are not inherently free.
For example, to_owned on an owned type is a no-op typically (it's a blanket implementation).
Clone on a unit struct or a unit enum variant is also a no-op in most cases (unless explicitly implemented not to be, which is very much frowned upon).