I have a JavaScript object type where the kind
field determines what other fields are present. Examples:
{ kind: 0, name: "foo" }
{ kind: 1, name: "foo", value: 69 }
{ kind: 2 }
I put it into an extern
block to use it in Rust:
#[wasm_bindgen]
extern "C" {
type Foo;
}
I need to access a Foo
value's fields in this function:
#[wasm_bindgen]
fn use_foo(foo: Foo) {
// ...
}
How do I do this in a type-safe way?