Trait eso::borrow::Borrow[][src]

pub trait Borrow<'a, T: 'a> {
    fn borrow(&'a self) -> T;
}
Expand description

A value that can be borrowed as a generalized reference of type T.

let value = String::from("Hello World");
let reference: &str = value.borrow();

The difference to Borrow is that this trait allows you to return types that are not actually references, such as Cows:

let value = String::from("Hello World");
let reference: Cow<str> = value.borrow();

Required methods

fn borrow(&'a self) -> T[src]

Borrow a generalized reference of type T.

Implementations on Foreign Types

impl<'a, T: ?Sized> Borrow<'a, &'a T> for Box<T>[src]

fn borrow(&'a self) -> &'a T[src]

impl<'a, T: ?Sized> Borrow<'a, &'a T> for Arc<T>[src]

fn borrow(&'a self) -> &'a T[src]

impl<'a, T: ?Sized> Borrow<'a, &'a T> for Rc<T>[src]

fn borrow(&'a self) -> &'a T[src]

impl<'a> Borrow<'a, &'a str> for String[src]

fn borrow(&'a self) -> &'a str[src]

impl<'a> Borrow<'a, &'a [u8]> for String[src]

fn borrow(&'a self) -> &'a [u8][src]

impl<'a> Borrow<'a, &'a Path> for PathBuf[src]

fn borrow(&self) -> &Path[src]

impl<'a, T> Borrow<'a, &'a [T]> for Vec<T>[src]

fn borrow(&self) -> &[T][src]

impl<'a> Borrow<'a, &'a OsStr> for OsString[src]

fn borrow(&self) -> &OsStr[src]

impl<'a> Borrow<'a, &'a OsStr> for PathBuf[src]

fn borrow(&self) -> &OsStr[src]

impl<'a> Borrow<'a, &'a CStr> for CString[src]

fn borrow(&self) -> &CStr[src]

impl<'a, 'b: 'a, T: ?Sized> Borrow<'a, &'a T> for &'b T[src]

fn borrow(&'a self) -> &'a T[src]

Implementors

impl<'a, T> Borrow<'a, &'a T> for T[src]

fn borrow(&'a self) -> &'a T[src]

impl<'a, T, R: ?Sized> Borrow<'a, Cow<'a, R>> for T where
    T: Borrow<R>,
    R: ToOwned<Owned = T>, 
[src]

fn borrow(&'a self) -> Cow<'_, R>[src]