Implement DerefMut

This commit is contained in:
Micha Reiser 2024-07-29 10:25:26 +02:00
parent 4995ce0ddc
commit 12e0741252
No known key found for this signature in database
2 changed files with 13 additions and 0 deletions

View file

@ -196,6 +196,15 @@ impl<U: UserData> std::ops::Deref for DatabaseImpl<U> {
}
}
impl<U: UserData> std::ops::DerefMut for DatabaseImpl<U> {
fn deref_mut(&mut self) -> &mut U {
self.zalsa_mut()
.user_data_mut()
.downcast_mut::<U>()
.unwrap()
}
}
impl<U: UserData + RefUnwindSafe> RefUnwindSafe for DatabaseImpl<U> {}
#[salsa_macros::db]

View file

@ -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 {