diff --git a/src/database.rs b/src/database.rs index aaa385d..2078100 100644 --- a/src/database.rs +++ b/src/database.rs @@ -196,6 +196,15 @@ impl std::ops::Deref for DatabaseImpl { } } +impl std::ops::DerefMut for DatabaseImpl { + fn deref_mut(&mut self) -> &mut U { + self.zalsa_mut() + .user_data_mut() + .downcast_mut::() + .unwrap() + } +} + impl RefUnwindSafe for DatabaseImpl {} #[salsa_macros::db] diff --git a/src/zalsa.rs b/src/zalsa.rs index ea4ae58..f18930f 100644 --- a/src/zalsa.rs +++ b/src/zalsa.rs @@ -179,6 +179,10 @@ impl Zalsa { &*self.user_data } + pub(crate) fn user_data_mut(&mut self) -> &mut (dyn Any + Send + Sync) { + &mut *self.user_data + } + /// Triggers a new revision. Invoked automatically when you call `zalsa_mut` /// and so doesn't need to be called otherwise. pub(crate) fn new_revision(&mut self) -> Revision {