Skip to content

Commit 2053e97

Browse files
author
Pat Hickey
authored
InstancePre can impl Clone (#3510)
Its a manually written impl, not a derive, because InstancePre<T>: 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?
1 parent 6be0f82 commit 2053e97

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

crates/wasmtime/src/instance.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,17 @@ pub struct InstancePre<T> {
905905
_marker: std::marker::PhantomData<fn() -> T>,
906906
}
907907

908+
/// InstancePre's clone does not require T: Clone
909+
impl<T> Clone for InstancePre<T> {
910+
fn clone(&self) -> Self {
911+
Self {
912+
module: self.module.clone(),
913+
items: self.items.clone(),
914+
_marker: self._marker,
915+
}
916+
}
917+
}
918+
908919
impl<T> InstancePre<T> {
909920
pub(crate) unsafe fn new(
910921
store: &mut StoreOpaque,

0 commit comments

Comments
 (0)