diff --git a/heed/src/txn.rs b/heed/src/txn.rs index 242c424c..a6f479d9 100644 --- a/heed/src/txn.rs +++ b/heed/src/txn.rs @@ -141,6 +141,15 @@ impl<'a> Deref for RoTxn<'a, WithTls> { } } +#[cfg(master3)] +impl<'a> std::ops::DerefMut for RoTxn<'a, WithTls> { + fn deref_mut(&mut self) -> &mut Self::Target { + // SAFETY: OK because repr(transparent) means RoTxn always has the same layout + // as RoTxnInner. + unsafe { std::mem::transmute(self) } + } +} + impl<'a> Deref for RoTxn<'a, WithoutTls> { type Target = RoTxn<'a, AnyTls>; @@ -151,6 +160,15 @@ impl<'a> Deref for RoTxn<'a, WithoutTls> { } } +#[cfg(master3)] +impl<'a> std::ops::DerefMut for RoTxn<'a, WithoutTls> { + fn deref_mut(&mut self) -> &mut Self::Target { + // SAFETY: OK because repr(transparent) means RoTxn always has the same layout + // as RoTxnInner. + unsafe { std::mem::transmute(self) } + } +} + impl Drop for RoTxn<'_, T> { fn drop(&mut self) { if let Some(mut txn) = self.inner.txn.take() {