From 2053e972b7dbee48a021d46e84502376133a8b27 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 8 Nov 2021 07:11:31 -0800 Subject: [PATCH] InstancePre can impl Clone (#3510) 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 bced7cfe4c..aec6c1ba06 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,