add Borrow implementation to make it easier to abstract over T and Guard<T>

This commit is contained in:
Greg Johnston
2024-02-21 10:49:43 -05:00
parent 992e2bce78
commit ddf2ac0cf7

View File

@@ -2,6 +2,7 @@ use crate::traits::Trigger;
use core::fmt::Debug;
use guardian::ArcRwLockReadGuardian;
use std::{
borrow::Borrow,
fmt::Display,
marker::PhantomData,
ops::{Deref, DerefMut},
@@ -34,6 +35,15 @@ where
}
}
impl<T, Inner> Borrow<T> for ReadGuard<T, Inner>
where
Inner: Deref<Target = T>,
{
fn borrow(&self) -> &T {
self.deref()
}
}
impl<T, Inner> PartialEq<T> for ReadGuard<T, Inner>
where
Inner: Deref<Target = T>,