MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / clone

Method clone

crates/c-api/src/val.rs:49–70  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

47
48impl Clone for wasm_val_t {
49 fn clone(&self) -> Self {
50 #[allow(
51 unused_mut,
52 reason = "needed for conditional mutation under cfg(feature = \"gc\")"
53 )]
54 let mut ret = wasm_val_t {
55 kind: self.kind,
56 of: self.of,
57 };
58
59 #[cfg(feature = "gc")]
60 unsafe {
61 match self.kind {
62 WASM_FUNCREF | WASM_EXTERNREF if !self.of.ref_.is_null() => {
63 ret.of.ref_ = Box::into_raw(Box::new((*self.of.ref_).clone()));
64 }
65 _ => {}
66 }
67 }
68
69 return ret;
70 }
71}
72
73impl Default for wasm_val_t {

Calls 2

is_nullMethod · 0.80
newFunction · 0.50