Add support for fetching/rendering images

This commit is contained in:
Nathan Sobo 2023-09-06 17:13:38 -06:00
parent 6d4dd0e7a4
commit 99ad60460a
7 changed files with 161 additions and 32 deletions

View file

@ -1,11 +1,22 @@
use std::sync::Arc;
#[derive(PartialEq, Eq, Hash)]
#[derive(PartialEq, Eq)]
pub enum ArcCow<'a, T: ?Sized> {
Borrowed(&'a T),
Owned(Arc<T>),
}
use std::hash::{Hash, Hasher};
impl<'a, T: ?Sized + Hash> Hash for ArcCow<'a, T> {
fn hash<H: Hasher>(&self, state: &mut H) {
match self {
Self::Borrowed(borrowed) => Hash::hash(borrowed, state),
Self::Owned(owned) => Hash::hash(&**owned, state),
}
}
}
impl<'a, T: ?Sized> Clone for ArcCow<'a, T> {
fn clone(&self) -> Self {
match self {