| Crates.io | xref |
| lib.rs | xref |
| version | 0.1.1 |
| created_at | 2020-08-13 21:50:39.38866+00 |
| updated_at | 2020-08-13 21:52:51.590208+00 |
| description | Like Cow, but also works with RefCell |
| homepage | |
| repository | https://github.com/math4tots/xref |
| max_upload_size | |
| id | 276361 |
| size | 19,551 |
When you want to return some data that might be either
owned or borrowed, it is common to return a Cow<T>.
However, Cow<T> has the following limitations:
T has to be ToOwned, andRefCell,
you can't.XRef<T> is like Cow<T>, except addresses the above
limitations with the following differences:
T does not have to be ToOwned, (this means that
now the type contained in Borrowed and Owned have to
contain the exact matching types), andXRef<T> has a third variant Ref which holds a
std::cell::Ref<T>, for cases when the value is borrowed
from a RefCell.XRefMut<T> is like XRef<T> except that
XRef::Borrowed holds
a &mut T instead of &T, XRef::Ref holds a RefMut<T>
instead of a Ref<T>),XRefMut<T> implements DerefMut<T>, to allow borrowing
data mutably without cloning.