Make automatically the trait Into<Engine> conversions

This commit is contained in:
Syrus Akbary
2023-02-27 23:25:17 -08:00
parent fe72a5ab7f
commit 09427c3bb6
4 changed files with 6 additions and 27 deletions

View File

@@ -92,7 +92,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let global_count = data.g_counter.get(&mut storemut).unwrap_i32(); let global_count = data.g_counter.get(&mut storemut).unwrap_i32();
data.g_counter data.g_counter
.set(&mut storemut, Value::I32(global_count + add)); .set(&mut storemut, Value::I32(global_count + add))
.unwrap();
*counter_ref += add; *counter_ref += add;
*counter_ref *counter_ref

View File

@@ -8,7 +8,7 @@ use wasmer::{
}; };
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
// This is to be able to set the tunables // This is to be able to set the tunables
use wasmer::WasmerCompilerEngine; use wasmer::NativeEngineExt;
/// A custom tunables that allows you to set a memory limit. /// A custom tunables that allows you to set a memory limit.
/// ///

View File

@@ -42,22 +42,12 @@ impl Default for Engine {
} }
} }
impl From<engine_imp::Engine> for Engine { impl<T: Into<engine_imp::Engine>> From<T> for Engine {
fn from(inner: engine_imp::Engine) -> Self { fn from(t: T) -> Self {
Self(inner) Self(t.into())
} }
} }
// impl<P> Into<Engine> for P
// where
// P: Into<engine_imp::Engine>
// {
// fn into(self) -> Engine {
// let inner_engine: engine_imp::Engine = self.into();
// Engine(inner_engine)
// }
// }
/// A temporary handle to an [`Engine`] /// A temporary handle to an [`Engine`]
/// EngineRef can be used to build a [`Module`][wasmer::Module] /// EngineRef can be used to build a [`Module`][wasmer::Module]
/// It can be created directly with an [`Engine`] /// It can be created directly with an [`Engine`]

View File

@@ -51,18 +51,6 @@ pub(crate) fn default_engine() -> Engine {
engine engine
} }
impl From<EngineBuilder> for crate::engine::Engine {
fn from(builder: EngineBuilder) -> Self {
Self(builder.into())
}
}
// impl From<CompilerConfig> for crate::engine::Engine {
// fn from(compiler: CompilerConfig) -> Self {
// Self(compiler.into())
// }
// }
/// The custom trait to access to all the `sys` function in the common /// The custom trait to access to all the `sys` function in the common
/// engine. /// engine.
pub trait NativeEngineExt { pub trait NativeEngineExt {