Trait 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.

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 Bos<str> for String

Source§

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

Source§

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

Source§

impl Bos<CStr> for CString

Source§

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.
Source§

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.
Source§

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

Source§

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>

Source§

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>

Source§

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]

Source§

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

Source§

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>

Source§

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>

Source§

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>

Source§

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

Source§

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

Implementors§