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:
@@ -905,6 +905,17 @@ pub struct InstancePre<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> {
|
||||
pub(crate) unsafe fn new(
|
||||
store: &mut StoreOpaque,
|
||||
|
||||
Reference in New Issue
Block a user