Checkpoint

This commit is contained in:
Antonio Scandurra 2023-10-20 11:44:19 +02:00
parent b0acaed02f
commit 8a11053f1f
4 changed files with 104 additions and 27 deletions

View file

@ -1,16 +1,24 @@
use std::{
borrow::Cow,
fmt::{self, Debug},
hash::{Hash, Hasher},
sync::Arc,
};
#[derive(PartialEq, Eq)]
pub enum ArcCow<'a, T: ?Sized> {
Borrowed(&'a T),
Owned(Arc<T>),
}
use std::hash::{Hash, Hasher};
impl<'a, T: ?Sized + PartialEq> PartialEq for ArcCow<'a, T> {
fn eq(&self, other: &Self) -> bool {
let a = self.as_ref();
let b = other.as_ref();
a == b
}
}
impl<'a, T: ?Sized + Eq> Eq for ArcCow<'a, T> {}
impl<'a, T: ?Sized + Hash> Hash for ArcCow<'a, T> {
fn hash<H: Hasher>(&self, state: &mut H) {