|
1 | 1 | use crate::sys::tunables::BaseTunables;
|
2 | 2 | use derivative::Derivative;
|
3 |
| -use std::fmt; |
| 3 | +use std::{ |
| 4 | + fmt, |
| 5 | + ops::{Deref, DerefMut}, |
| 6 | +}; |
4 | 7 | #[cfg(feature = "compiler")]
|
5 | 8 | use wasmer_compiler::{AsEngineRef, Engine, EngineBuilder, EngineRef, Tunables};
|
6 | 9 | use wasmer_types::OnCalledAction;
|
@@ -220,13 +223,6 @@ impl AsEngineRef for Store {
|
220 | 223 | }
|
221 | 224 | }
|
222 | 225 |
|
223 |
| -#[cfg(feature = "compiler")] |
224 |
| -impl AsEngineRef for &Store { |
225 |
| - fn as_engine_ref(&self) -> EngineRef<'_> { |
226 |
| - EngineRef::new(&self.engine) |
227 |
| - } |
228 |
| -} |
229 |
| - |
230 | 226 | #[cfg(feature = "compiler")]
|
231 | 227 | impl AsEngineRef for StoreRef<'_> {
|
232 | 228 | fn as_engine_ref(&self) -> EngineRef<'_> {
|
@@ -374,21 +370,26 @@ impl AsStoreMut for StoreMut<'_> {
|
374 | 370 | }
|
375 | 371 | }
|
376 | 372 |
|
377 |
| -impl<T: AsStoreRef> AsStoreRef for &'_ T { |
| 373 | +impl<P> AsStoreRef for P |
| 374 | +where |
| 375 | + P: Deref, |
| 376 | + P::Target: AsStoreRef, |
| 377 | +{ |
378 | 378 | fn as_store_ref(&self) -> StoreRef<'_> {
|
379 |
| - T::as_store_ref(*self) |
| 379 | + (**self).as_store_ref() |
380 | 380 | }
|
381 | 381 | }
|
382 |
| -impl<T: AsStoreRef> AsStoreRef for &'_ mut T { |
383 |
| - fn as_store_ref(&self) -> StoreRef<'_> { |
384 |
| - T::as_store_ref(*self) |
385 |
| - } |
386 |
| -} |
387 |
| -impl<T: AsStoreMut> AsStoreMut for &'_ mut T { |
| 382 | + |
| 383 | +impl<P> AsStoreMut for P |
| 384 | +where |
| 385 | + P: DerefMut, |
| 386 | + P::Target: AsStoreMut, |
| 387 | +{ |
388 | 388 | fn as_store_mut(&mut self) -> StoreMut<'_> {
|
389 |
| - T::as_store_mut(*self) |
| 389 | + (**self).as_store_mut() |
390 | 390 | }
|
| 391 | + |
391 | 392 | fn objects_mut(&mut self) -> &mut StoreObjects {
|
392 |
| - T::objects_mut(*self) |
| 393 | + (**self).objects_mut() |
393 | 394 | }
|
394 | 395 | }
|
0 commit comments