rxpect/borrow.rs
1/// A simpler version of Cow that can only borrow values, not convert them into owned.
2pub enum BorrowedOrOwned<'a, T> {
3 Borrowed(&'a T),
4 Owned(T),
5}
6
7impl<'a, T> BorrowedOrOwned<'a, T> {
8 /// Borrows this value with a lifetime that matches self
9 pub fn borrow_self(&'a self) -> &'a T {
10 match self {
11 BorrowedOrOwned::Borrowed(reference) => reference,
12 BorrowedOrOwned::Owned(owned) => owned,
13 }
14 }
15}