From c4f261af155017eae09dc0b86a395090b0dfbf41 Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Thu, 14 Sep 2023 07:59:44 -0700 Subject: [PATCH] impl `Clone` for `wasmtime::component::Linker` (#7032) The core Wasm `Linker` type is clone, and the component linker needs to be used in similar settings where clonability is important. --- crates/wasmtime/src/component/linker.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/wasmtime/src/component/linker.rs b/crates/wasmtime/src/component/linker.rs index 2317a833ef..8efbbcbfe1 100644 --- a/crates/wasmtime/src/component/linker.rs +++ b/crates/wasmtime/src/component/linker.rs @@ -31,7 +31,20 @@ pub struct Linker { _marker: marker::PhantomData T>, } -#[derive(Default)] +impl Clone for Linker { + fn clone(&self) -> Linker { + Linker { + engine: self.engine.clone(), + strings: self.strings.clone(), + map: self.map.clone(), + path: self.path.clone(), + allow_shadowing: self.allow_shadowing, + _marker: self._marker, + } + } +} + +#[derive(Clone, Default)] pub struct Strings { string2idx: HashMap, usize>, strings: Vec>,