Hi,
Relatively new to Rust and I've been working with wasm_bindgen for a project. I need to be able to generate javascript for a struct I've defined in rust but get an error decorating it with
#[wasm_bindgen]
The error messages I'm seeing are,
the trait bound `std::boxed::Box<ListNode>: wasm_bindgen::convert::OptionIntoWasmAbi` is not satisfied
the trait `wasm_bindgen::convert::OptionIntoWasmAbi` is not implemented for `std::boxed::Box<ListNode>`
help: the following implementations were found:
<std::boxed::Box<[T]> as wasm_bindgen::convert::OptionIntoWasmAbi>
<std::boxed::Box<[f32]> as wasm_bindgen::convert::OptionIntoWasmAbi>
<std::boxed::Box<[f64]> as wasm_bindgen::convert::OptionIntoWasmAbi>
<std::boxed::Box<[i16]> as wasm_bindgen::convert::OptionIntoWasmAbi>
and 10 others
note: required because of the requirements on the impl of `wasm_bindgen::convert::IntoWasmAbi` for `std::option::Option<std::boxed::Box<ListNode>>`rustc(E0277)
lib.rs(41, 1): the trait `wasm_bindgen::convert::OptionIntoWasmAbi` is not implemented for `std::boxed::Box<ListNode>`
and
the trait bound `std::boxed::Box<ListNode>: std::marker::Copy` is not satisfied
the trait `std::marker::Copy` is not implemented for `std::boxed::Box<ListNode>`
note: required because of the requirements on the impl of `std::marker::Copy` for `std::option::Option<std::boxed::Box<ListNode>>`rustc(E0277)
lib.rs(41, 1): required by this bound in `__wbg_get_listnode_next__const::__wbg_get_listnode_next::assert_copy`
lib.rs(45, 15): the trait `std::marker::Copy` is not implemented for `std::boxed::Box<ListNode>`
The implementation for the struct looks like...
#[wasm_bindgen]
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
#[wasm_bindgen]
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
}
}
How can I go about accomplishing this?
Thanks!