pub trait OwnedOrBorrowed<T>: Sealed {
    type Inner: Borrow<T>;

    const OWNED: bool;

    // Required methods
    fn into_inner(self) -> Self::Inner;
    fn as_inner(&self) -> &Self::Inner;
}
Expand description

A trait for abstracting over an owned value or borrowed reference to a type T.

You cannot implement this trait; it can only be used with Owned or Borrowed.

The Owned and Borrowed wrapper types implement the following traits:

Required Associated Types§

source

type Inner: Borrow<T>

The inner type of the owned value or borrowed reference.

Required Associated Constants§

source

const OWNED: bool

  • true if the wrapper type contains an owned value, i.e., for Owned.
  • false if the wrapper type contains a borrowed reference, i.e., for Borrowed.

Required Methods§

source

fn into_inner(self) -> Self::Inner

Consumes this wrapper type and returns the contained value or borrowed reference.

source

fn as_inner(&self) -> &Self::Inner

Returns a reference to the inner value.

Implementors§

source§

impl<'t, T> OwnedOrBorrowed<T> for Borrowed<'t, T>

source§

const OWNED: bool = false

§

type Inner = &'t T

source§

impl<T> OwnedOrBorrowed<T> for Owned<T>

source§

const OWNED: bool = true

§

type Inner = T