From e8331661cb9bd29fbaa04f75a51ce5cc295fba2f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 8 Mar 2023 11:13:28 -0600 Subject: [PATCH] Add `Clone for component::InstancePre` (#5966) This is present on `wasmtime::InstancePre` and should be available for components as well. Closes #5965 --- crates/wasmtime/src/component/instance.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/wasmtime/src/component/instance.rs b/crates/wasmtime/src/component/instance.rs index 39853e330c..81c526c1c6 100644 --- a/crates/wasmtime/src/component/instance.rs +++ b/crates/wasmtime/src/component/instance.rs @@ -194,6 +194,7 @@ struct Instantiator<'a> { imports: &'a PrimaryMap, } +#[derive(Clone)] pub enum RuntimeImport { Func(Arc), Module(Module), @@ -464,6 +465,17 @@ pub struct InstancePre { _marker: marker::PhantomData T>, } +// `InstancePre`'s clone does not require `T: Clone` +impl Clone for InstancePre { + fn clone(&self) -> Self { + Self { + component: self.component.clone(), + imports: self.imports.clone(), + _marker: self._marker, + } + } +} + impl InstancePre { /// This function is `unsafe` since there's no guarantee that the /// `RuntimeImport` items provided are guaranteed to work with the `T` of