Trait borrow_or_share::Bos

source ·
pub trait Bos<T: ?Sized> {
    type Ref<'this>: Ref<T>
       where Self: 'this;

    // Required method
    fn borrow_or_share(this: &Self) -> Self::Ref<'_>;
}
Expand description

A trait for either borrowing or sharing data.

See the crate-level documentation for more details.

Required Associated Types§

source

type Ref<'this>: Ref<T> where Self: 'this

The resulting reference type. May only be &T.

Required Methods§

source

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

Borrows from *this or from behind a reference it holds, returning a reference of type Self::Ref.

In the latter case, the returned reference is said to be shared with *this.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Bos<str> for String

§

type Ref<'this> = &'this str where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl Bos<CStr> for CString

§

type Ref<'this> = &'this CStr where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl Bos<OsStr> for OsString

Available on crate feature std only.
§

type Ref<'this> = &'this OsStr where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl Bos<Path> for PathBuf

Available on crate feature std only.
§

type Ref<'this> = &'this Path where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<'a, T: ?Sized> Bos<T> for &'a T

§

type Ref<'this> = &'a T where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<B: ?Sized + ToOwned> Bos<B> for Cow<'_, B>

§

type Ref<'this> = &'this B where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<T> Bos<[T]> for Vec<T>

§

type Ref<'this> = &'this [T] where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<T, const N: usize> Bos<[T]> for [T; N]

§

type Ref<'this> = &'this [T] where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<T: ?Sized> Bos<T> for &mut T

§

type Ref<'this> = &'this T where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<T: ?Sized> Bos<T> for Box<T>

§

type Ref<'this> = &'this T where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<T: ?Sized> Bos<T> for Rc<T>

§

type Ref<'this> = &'this T where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

source§

impl<T: ?Sized> Bos<T> for Arc<T>

§

type Ref<'this> = &'this T where Self: 'this

source§

fn borrow_or_share(this: &Self) -> Self::Ref<'_>

Implementors§