This commit is contained in:
Nathan Sobo 2023-10-10 22:49:47 -06:00
parent f53b63eaf6
commit f1cc62c21f
8 changed files with 96 additions and 42 deletions

View file

@ -57,6 +57,18 @@ impl<'a> From<Cow<'a, str>> for ArcCow<'a, str> {
}
}
impl<T> From<Vec<T>> for ArcCow<'_, [T]> {
fn from(vec: Vec<T>) -> Self {
ArcCow::Owned(Arc::from(vec))
}
}
impl<'a> From<&'a str> for ArcCow<'a, [u8]> {
fn from(s: &'a str) -> Self {
ArcCow::Borrowed(s.as_bytes())
}
}
impl<'a, T: ?Sized + ToOwned> std::borrow::Borrow<T> for ArcCow<'a, T> {
fn borrow(&self) -> &T {
match self {