Trait lifetime::ToBorrowed[][src]

pub trait ToBorrowed {
    type Borrowed;
    fn to_borrowed(self) -> Self::Borrowed;
}
Expand description

A trait for downgrading the lifetime of a type.

Examples

use lifetime::ToBorrowed;
use std::borrow::Cow;

let owned: Cow<'static, str> = Cow::Owned(String::from("Hi"));
let mut borrowed: Cow<'_, str> = owned.to_borrowed();

assert_eq!(borrowed, "Hi");
assert_matches::assert_matches!(borrowed, Cow::Borrowed(_));

borrowed = Cow::Borrowed("Bye");
assert_eq!(owned, "Hi");

Associated Types

Required methods

Implementations on Foreign Types

Implementors