Skip to main content

RefToOwned

Trait RefToOwned 

Source
pub trait RefToOwned<'a> {
    type Owned: OwnedToRef<Borrowed<'a> = Self>
       where Self: 'a;

    // Required method
    fn ref_to_owned(&self) -> Self::Owned;
}
Expand description

A trait for cloning a referenced structure and getting owned objects

This is the pendant to OwnedToRef

Required Associated Types§

Source

type Owned: OwnedToRef<Borrowed<'a> = Self> where Self: 'a

The resulting type after obtaining ownership.

Required Methods§

Source

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

Creates a new object taking ownership of the data

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, T> RefToOwned<'a> for Option<T>
where T: RefToOwned<'a> + 'a, T::Owned: OwnedToRef,

Source§

type Owned = Option<<T as RefToOwned<'a>>::Owned>

Source§

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

Source§

impl<'a> RefToOwned<'a> for &'a [u8]

Source§

type Owned = Box<[u8]>

Source§

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

Implementors§