From ee153bfc57b76c6d33625ea3e50f777a84c2bc12 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 5 Nov 2021 17:04:59 -0700 Subject: [PATCH] InstancePre can impl Clone Its a manually written impl, not a derive, because InstancePre: Clone does not require T: Clone. The clone should be reasonably inexpensive: Clone for Module is just an Arc, and Clone for Definition should also just be an Arc on the HostFunc or Instance variants. An InstancePre shouldnt contain any Definition::Extern variants because there is not yet a Store associated with it- right? --- crates/wasmtime/src/instance.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/wasmtime/src/instance.rs b/crates/wasmtime/src/instance.rs index bced7cfe4c95..aec6c1ba06f6 100644 --- a/crates/wasmtime/src/instance.rs +++ b/crates/wasmtime/src/instance.rs @@ -905,6 +905,17 @@ pub struct InstancePre { _marker: std::marker::PhantomData T>, } +/// InstancePre's clone does not require T: Clone +impl Clone for InstancePre { + fn clone(&self) -> Self { + Self { + module: self.module.clone(), + items: self.items.clone(), + _marker: self._marker, + } + } +} + impl InstancePre { pub(crate) unsafe fn new( store: &mut StoreOpaque,