diff options
| author | Botahamec <botahamec@outlook.com> | 2024-09-26 22:12:52 -0400 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2024-09-26 22:12:52 -0400 |
| commit | 00991791bba57a8757ba207a573e360224f43e6e (patch) | |
| tree | b108bf3172ee31d676da8e6418d1a5e31aa7394e /src/poisonable/guard.rs | |
| parent | 4fd5136e0c0ec9cc92bb2b5735c0b3b68acdd755 (diff) | |
Docs and improvements
Diffstat (limited to 'src/poisonable/guard.rs')
| -rw-r--r-- | src/poisonable/guard.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/poisonable/guard.rs b/src/poisonable/guard.rs index 97b0028..a8a54fe 100644 --- a/src/poisonable/guard.rs +++ b/src/poisonable/guard.rs @@ -1,10 +1,23 @@ use std::fmt::{Debug, Display}; +use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::sync::atomic::Ordering::Relaxed; use crate::Keyable; -use super::{PoisonGuard, PoisonRef}; +use super::{PoisonFlag, PoisonGuard, PoisonRef}; + +impl<'a, Guard> PoisonRef<'a, Guard> { + // This is used so that we don't keep accidentally adding the flag reference + pub(super) const fn new(flag: &'a PoisonFlag, guard: Guard) -> Self { + Self { + guard, + #[cfg(panic = "unwind")] + flag, + _phantom: PhantomData, + } + } +} impl<'flag, Guard> Drop for PoisonRef<'flag, Guard> { fn drop(&mut self) { |
