perlmod: add missing drop handler for RawGuard

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2024-07-30 15:42:06 +02:00
parent 1624184105
commit 3b56a68df4

View File

@ -15,6 +15,12 @@ thread_local!(static SERIALIZE_RAW: RefCell<bool> = RefCell::new(false));
pub(crate) struct RawGuard(bool);
impl Drop for RawGuard {
fn drop(&mut self) {
SERIALIZE_RAW.with(|raw| *raw.borrow_mut() = self.0);
}
}
#[inline]
pub(crate) fn guarded(on: bool) -> RawGuard {
SERIALIZE_RAW.with(move |raw| RawGuard(raw.replace(on)))