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 Cow
s:
let value = String::from("Hello World"); let reference: Cow<str> = value.borrow();