Closed Licenser closed 4 years ago
This operation would probably be best called unwrap_borrowed
as currently written.
If given a choice, I'd expect:
fn as_borrowed(&self) -> Option<&'a T> {
match self {
Cow::Owned(_) => None,
Cow::Borrowed(borrowed) => Some(borrowed),
}
}
fn as_owned(&self) -> Option<&T::Owned> {
match self {
Cow::Owned(owned) => Some(owned),
Cow::Borrowed(_) => None,
}
}
fn as_owned_mut(&mut self) -> Option<&mut T::Owned> {
match self {
Cow::Owned(owned) => Some(owned),
Cow::Borrowed(_) => None,
}
}
that's a much better name! I'll update it to unwrap_borrowed
:)
Thanks for the PR! Released as 0.4.1.
The function will consume the Cow and return the borrowed data with the associated lifetime. It panics if the data wasn't borrowed.
closes #19