Skip to main content

OwnedToRef

Trait OwnedToRef 

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

    // Required method
    fn owned_to_ref(&self) -> Self::Borrowed<'_>;
}
Expand description

A trait for borrowing data from an owned struct

This converts an object owning the data to one that will borrowing the content. The newly created object lifetime will be tied to the object owning the data.

This is similar to alloc::borrow::Borrow or core::convert::AsRef but this returns an owned structure that references directly the backing slices instead of borrowing the whole structure.

Required Associated Types§

Source

type Borrowed<'a> where Self: 'a

The resulting type referencing back to Self

Required Methods§

Source

fn owned_to_ref(&self) -> Self::Borrowed<'_>

Creates a new object referencing back to the self for storage

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 OwnedToRef for Box<[u8]>

Available on crate feature alloc only.
Source§

type Borrowed<'a> = &'a [u8]

Source§

fn owned_to_ref(&self) -> Self::Borrowed<'_>

Source§

impl<T> OwnedToRef for Option<T>
where T: OwnedToRef,

Source§

type Borrowed<'a> = Option<<T as OwnedToRef>::Borrowed<'a>> where T: 'a

Source§

fn owned_to_ref(&self) -> Self::Borrowed<'_>

Implementors§

Source§

impl OwnedToRef for Any

Available on crate feature alloc only.
Source§

type Borrowed<'a> = AnyRef<'a>

Source§

impl OwnedToRef for BitString

Available on crate feature alloc only.
Source§

impl OwnedToRef for Ia5String

Available on crate feature alloc only.
Source§

impl OwnedToRef for Int

Available on crate feature alloc only.
Source§

type Borrowed<'a> = IntRef<'a>

Source§

impl OwnedToRef for PrintableString

Available on crate feature alloc only.
Source§

impl OwnedToRef for TeletexString

Available on crate feature alloc only.
Source§

impl OwnedToRef for Uint

Available on crate feature alloc only.
Source§

type Borrowed<'a> = UintRef<'a>