`ToOwned` is a bad name for the trait

Getters in Rust are typically nouns, the name of the field. The as/to/into convention comes from that side of the naming conventions, things that are not fields but are nonetheless nouny (like the concrete to_string and into_boxed_slice).

On the other side, own() is a terrible name for the operation in question, because the object in question isn’t doing the “owning”. It isn’t even “being owned”. It’s being copied into a different form. So maybe it could have been called something like clone_for_owning, but no, I don’t actually think to_owned is a bad name. I don’t know if I think it’s a perfect name, but sometimes the natural name for an operation focuses on a verb and sometimes it doesn’t, and yes, it’s a little awkward when you have to talk about both AsRef and Borrow at the same time.

6 Likes

If you're suggesting the name be changed, that ship sailed when the trait was stabilized. So it's a bit of a moot point I'm afraid.

to_ methods do not conventionally consume self, are you confusing it with into_, which is conventionally associated with consuming self?