pub trait IntoOwned<'a> {
type Owned;
// Required methods
fn into_owned(self) -> Self::Owned;
fn clone_onto(self, other: &mut Self::Owned);
fn borrow_as(owned: &'a Self::Owned) -> Self;
}
Expand description
A reference type corresponding to an owned type, supporting conversion in each direction.
This trait can be implemented by a GAT, and enables owned types to be borrowed as a GAT.
This trait is analogous to ToOwned
, but not as prescriptive. Specifically, it avoids the
requirement that the other trait implement Borrow
, for which a borrow must result in a
&'self Borrowed
, which cannot move the lifetime into a GAT borrowed type.
Required Associated Types§
Required Methods§
Sourcefn into_owned(self) -> Self::Owned
fn into_owned(self) -> Self::Owned
Conversion from an instance of this type to the owned type.
Sourcefn clone_onto(self, other: &mut Self::Owned)
fn clone_onto(self, other: &mut Self::Owned)
Clones self
onto an existing instance of the owned type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.