Implement Clone for ModuleInstance
...because of the contained Rc it's otherwise just a shallow clone, not a deep.
This commit is contained in:
parent
327d93c785
commit
a1ea2d689f
|
@ -169,6 +169,31 @@ pub struct ModuleInstance {
|
||||||
exports: RefCell<BTreeMap<String, ExternVal>>,
|
exports: RefCell<BTreeMap<String, ExternVal>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Clone for ModuleInstance {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
let signatures = self.signatures.borrow();
|
||||||
|
let vec = &(*signatures);
|
||||||
|
let signatures = vec
|
||||||
|
.iter()
|
||||||
|
.map(|inner_rc| {
|
||||||
|
let signature = &**inner_rc;
|
||||||
|
let signature_clone = signature.clone();
|
||||||
|
Rc::new(signature_clone)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
let signatures = RefCell::new(signatures);
|
||||||
|
|
||||||
|
ModuleInstance {
|
||||||
|
signatures,
|
||||||
|
tables: self.tables.clone(),
|
||||||
|
funcs: self.funcs.clone(),
|
||||||
|
memories: self.memories.clone(),
|
||||||
|
globals: self.globals.clone(),
|
||||||
|
exports: self.exports.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ModuleInstance {
|
impl ModuleInstance {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ModuleInstance {
|
ModuleInstance {
|
||||||
|
|
Loading…
Reference in New Issue