summaryrefslogtreecommitdiff
path: root/src/poisonable/guard.rs
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2024-09-26 22:39:09 -0400
committerBotahamec <botahamec@outlook.com>2024-09-26 22:39:09 -0400
commit5f55113a6ead937fc8bc81e361abc09b3a1565f3 (patch)
treea8858abcb05d3796aec89e0fddff5e9ab18a873d /src/poisonable/guard.rs
parentaf4013c53e12bfad11bc33c060532320e33729a7 (diff)
Reduce the number of dereferences needed
Diffstat (limited to 'src/poisonable/guard.rs')
-rw-r--r--src/poisonable/guard.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/poisonable/guard.rs b/src/poisonable/guard.rs
index a8a54fe..d1913bf 100644
--- a/src/poisonable/guard.rs
+++ b/src/poisonable/guard.rs
@@ -68,27 +68,33 @@ impl<'flag, Guard> AsMut<Guard> for PoisonRef<'flag, Guard> {
impl<'flag, 'key, Guard: Debug, Key: Keyable> Debug for PoisonGuard<'flag, 'key, Guard, Key> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- Debug::fmt(&**self, f)
+ Debug::fmt(&self.guard, f)
}
}
impl<'flag, 'key, Guard: Display, Key: Keyable> Display for PoisonGuard<'flag, 'key, Guard, Key> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- Display::fmt(&**self, f)
+ Display::fmt(&self.guard, f)
}
}
-impl<'flag, 'key, Guard, Key: Keyable> Deref for PoisonGuard<'flag, 'key, Guard, Key> {
- type Target = Guard;
+impl<'flag, 'key, T, Guard: Deref<Target = T>, Key: Keyable> Deref
+ for PoisonGuard<'flag, 'key, Guard, Key>
+{
+ type Target = T;
fn deref(&self) -> &Self::Target {
- &self.guard.guard
+ #[allow(clippy::explicit_auto_deref)] // fixing this results in a compiler error
+ &*self.guard.guard
}
}
-impl<'flag, 'key, Guard, Key: Keyable> DerefMut for PoisonGuard<'flag, 'key, Guard, Key> {
+impl<'flag, 'key, T, Guard: DerefMut<Target = T>, Key: Keyable> DerefMut
+ for PoisonGuard<'flag, 'key, Guard, Key>
+{
fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.guard.guard
+ #[allow(clippy::explicit_auto_deref)] // fixing this results in a compiler error
+ &mut *self.guard.guard
}
}