It's often not possible to implement ToOwned for user composite types #44950
Labels
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
&str
and&[u8]
seems to work by internal magic but it is hard to implementToOwned
for user composite types. Consider:It is not possible to mark that
FooBuf
is an owned version ofFoo
as it would require implementingBorrow
forFooBuf
. However it is not possible to implementfn borrow(&FooBuf) -> &Foo
as we don't have anywhere we can storeFoo
. Built-in types workaround it by handling&str
and similar types separately from&T
and packing the actual structure there.(I know too little about type system to create any RFR which would fix it)
The text was updated successfully, but these errors were encountered: