API Proposal: Option::owned

I find myself writing x.map(ToOwned::to_owned) quite a bit to convert &str to String. Obviously the code quite quickly changes to x.map(String::from) for clarity in those situations but I would find x.owned() quite appealing that maps the inner value through ToOwned similar to how cloned() works.

I did not find a previous discussion about this, but that seems like a relatively straightforward API to me.

Has there been one?

1 Like

Has there been one?

A little bit: Is there to_owned for Options?