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?
This commit is contained in:
Pat Hickey
2021-11-08 07:11:31 -08:00
committed by GitHub
parent 6be0f82b96
commit 2053e972b7

View File

@@ -905,6 +905,17 @@ pub struct InstancePre<T> {
_marker: std::marker::PhantomData<fn() -> T>, _marker: std::marker::PhantomData<fn() -> T>,
} }
/// InstancePre's clone does not require T: Clone
impl<T> Clone for InstancePre<T> {
fn clone(&self) -> Self {
Self {
module: self.module.clone(),
items: self.items.clone(),
_marker: self._marker,
}
}
}
impl<T> InstancePre<T> { impl<T> InstancePre<T> {
pub(crate) unsafe fn new( pub(crate) unsafe fn new(
store: &mut StoreOpaque, store: &mut StoreOpaque,