borrow_framework

Trait ToOwned

Source
pub trait ToOwned: Sized {
    type Owned;

    // Required method
    fn to_owned(&self) -> Self::Owned;

    // Provided method
    fn into_owned(self) -> Self::Owned { ... }
}
Expand description

Convert from a borrowed type into an owned type.

This is similar to std::borrow::ToOwned but is meant for types with internal references, with support for into_owned and an additional Sized constraint.

Required Associated Types§

Source

type Owned

Owned type.

Required Methods§

Source

fn to_owned(&self) -> Self::Owned

Create an owned version of this type by cloning if necessary.

Provided Methods§

Source

fn into_owned(self) -> Self::Owned

Create an owned version of this type, consuming self.

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.

Implementations on Foreign Types§

Source§

impl<T> ToOwned for Cow<'_, T>
where T: ToOwned + 'static, T::Owned: Clone,

Source§

type Owned = Cow<'static, T>

Source§

fn to_owned(&self) -> Cow<'static, T>

Source§

fn into_owned(self) -> Cow<'static, T>

Implementors§

Source§

impl<'a, T> ToOwned for borrow_framework::Cow<'a, T>
where T: Cowable, CowableBorrowed<'a, T>: ToOwned<Owned = CowableOwned<T>>, CowableOwned<T>: Clone,

Source§

type Owned = Cow<'static, T>