mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-25 04:27:52 +00:00
Implement DerefMut
This commit is contained in:
parent
4995ce0ddc
commit
12e0741252
2 changed files with 13 additions and 0 deletions
|
@ -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> {}
|
impl<U: UserData + RefUnwindSafe> RefUnwindSafe for DatabaseImpl<U> {}
|
||||||
|
|
||||||
#[salsa_macros::db]
|
#[salsa_macros::db]
|
||||||
|
|
|
@ -179,6 +179,10 @@ impl Zalsa {
|
||||||
&*self.user_data
|
&*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`
|
/// Triggers a new revision. Invoked automatically when you call `zalsa_mut`
|
||||||
/// and so doesn't need to be called otherwise.
|
/// and so doesn't need to be called otherwise.
|
||||||
pub(crate) fn new_revision(&mut self) -> Revision {
|
pub(crate) fn new_revision(&mut self) -> Revision {
|
||||||
|
|
Loading…
Reference in a new issue