Add Clone for component::InstancePre (#5966)

This is present on `wasmtime::InstancePre` and should be available for
components as well.

Closes #5965
This commit is contained in:
Alex Crichton
2023-03-08 11:13:28 -06:00
committed by GitHub
parent 013b35ff32
commit e8331661cb

View File

@@ -194,6 +194,7 @@ struct Instantiator<'a> {
imports: &'a PrimaryMap<RuntimeImportIndex, RuntimeImport>,
}
#[derive(Clone)]
pub enum RuntimeImport {
Func(Arc<HostFunc>),
Module(Module),
@@ -464,6 +465,17 @@ pub struct InstancePre<T> {
_marker: marker::PhantomData<fn() -> T>,
}
// `InstancePre`'s clone does not require `T: Clone`
impl<T> Clone for InstancePre<T> {
fn clone(&self) -> Self {
Self {
component: self.component.clone(),
imports: self.imports.clone(),
_marker: self._marker,
}
}
}
impl<T> InstancePre<T> {
/// This function is `unsafe` since there's no guarantee that the
/// `RuntimeImport` items provided are guaranteed to work with the `T` of