[][src]Trait beef::Beef

pub unsafe trait Beef: ToOwned {
    fn owned_into_parts(
        owned: Self::Owned
    ) -> (NonNull<Self>, Option<NonZeroUsize>);
unsafe fn owned_from_parts(
        ptr: NonNull<Self>,
        capacity: NonZeroUsize
    ) -> Self::Owned; }

Helper trait required by Cow<T> to extract capacity of owned variant of T, and manage conversions.

This can be only implemented on types that match requirements:

  • T::Owned has a capacity, which is an extra word that is absent in T.
  • T::Owned with capacity of 0 does not allocate memory.
  • T::Owned can be reconstructed from *mut T borrowed out of it, plus capacity.

Required methods

fn owned_into_parts(owned: Self::Owned) -> (NonNull<Self>, Option<NonZeroUsize>)

Convert T::Owned to NonNull<T> and capacity. Return None for 0 capacity.

unsafe fn owned_from_parts(
    ptr: NonNull<Self>,
    capacity: NonZeroUsize
) -> Self::Owned

Rebuild T::Owned from NonNull<T> and capacity. This can be done by the likes of Vec::from_raw_parts.

Loading content...

Implementors

impl Beef for str[src]

impl<T: Clone> Beef for [T][src]

Loading content...