pub trait ToOwning {
type Owning;
// Required method
fn to_owning(&self) -> Self::Owning;
}
Expand description
A generalization of ToOwned
.
ToOwning
is weaker than ToOwned
because there is no constraint of
Owning : Borrow<Self>
as there is on ToOwned::Owned
. Thus, ToOwning
represents a type which can be converted from a reference into a related
type that owns its contents, but unlike ToOwned
doesn’t necessarily let
you get a reference to the original type back out.
ToOwning
has a blanket implementation for T where T : ToOwned
, wherein
Owning = Owned
and to_owning = to_owned
. User-defined types which
implement ToOwning
but not ToOwned
typically should do so by calling
.to_owning()
on all their fields.