abi_stable::std_types::cow

Trait RCowCompatibleRef

Source
pub trait RCowCompatibleRef<'a>: ToOwned {
    type RefC: IntoOwned<ROwned = Self::ROwned, Target = Self>;
    type ROwned: Borrow<Self> + Into<Self::Owned> + From<Self::Owned>;

    // Required methods
    fn as_c_ref(from: &'a Self) -> Self::RefC;
    fn as_rust_ref(from: Self::RefC) -> &'a Self;
}
Expand description

For making a Cow<'a, Self> convertible into an RCow.

Required Associated Types§

Source

type RefC: IntoOwned<ROwned = Self::ROwned, Target = Self>

The (preferably) ffi-safe equivalent of &Self.

Source

type ROwned: Borrow<Self> + Into<Self::Owned> + From<Self::Owned>

The owned version of Self::RefC.

Required Methods§

Source

fn as_c_ref(from: &'a Self) -> Self::RefC

Converts a reference to an FFI-safe type

Source

fn as_rust_ref(from: Self::RefC) -> &'a Self

Converts an FFI-safe type to a reference

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<'a> RCowCompatibleRef<'a> for str

Source§

type RefC = RStr<'a>

Source§

type ROwned = RString

Source§

fn as_c_ref(from: &'a Self) -> Self::RefC

Source§

fn as_rust_ref(from: Self::RefC) -> &'a Self

Source§

impl<'a, T: Clone + 'a> RCowCompatibleRef<'a> for [T]

Source§

type RefC = RSlice<'a, T>

Source§

type ROwned = RVec<T>

Source§

fn as_c_ref(from: &'a Self) -> Self::RefC

Source§

fn as_rust_ref(from: Self::RefC) -> &'a Self

Implementors§

Source§

impl<'a, T: Clone + 'a> RCowCompatibleRef<'a> for T