Added FunctionEnvMut::data_end_store_mut (will help #3592)

This commit is contained in:
ptitSeb
2023-02-23 15:38:36 +01:00
parent 4d8163d296
commit a7579c052e
4 changed files with 174 additions and 0 deletions

View File

@@ -117,6 +117,17 @@ impl<T: Send + 'static> FunctionEnvMut<'_, T> {
func_env: self.func_env.clone(),
}
}
/// Borrows a new mutable reference of both the attached Store and host state
pub fn data_and_store_mut(&mut self) -> (&mut T, StoreMut) {
let data = self.func_env.as_mut(&mut self.store_mut) as *mut T;
// telling the borrow check to close his eyes here
// this is still relatively safe to do as func_env are
// stored in a specific vec of Store, separate from the other objects
// and not really directly accessible with the StoreMut
let data = unsafe { &mut *data };
(data, self.store_mut.as_store_mut())
}
}
impl<T> AsStoreRef for FunctionEnvMut<'_, T> {