I am trying to use rust in web developing now, But some complex data structure types, I don't know how to return. (do not want to use into_serde because I think it will cause extra overhead)
for example:
#[wasm_bindgen]
pub fn test_f32_2_vec() > Vec<[f32; 2]> {
let example = vec![[1.0, 2.0], [3.0, 4.0]];
return example;
}
and the result:
error[E0277]: the trait bound `std::boxed::Box<[[f32; 2]]>: wasm_bindgen::convert::IntoWasmAbi` is not satisfied
> src/wasm.rs:55:1

55  #[wasm_bindgen]
 ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::convert::IntoWasmAbi` is not implemented for `std::boxed::Box<[[f32; 2]]>`

= help: the following implementations were found:
<std::boxed::Box<[f32]> as wasm_bindgen::convert::IntoWasmAbi>
<std::boxed::Box<[f64]> as wasm_bindgen::convert::IntoWasmAbi>
<std::boxed::Box<[i16]> as wasm_bindgen::convert::IntoWasmAbi>
<std::boxed::Box<[i32]> as wasm_bindgen::convert::IntoWasmAbi>
and 9 others
= note: required because of the requirements on the impl of `wasm_bindgen::convert::IntoWasmAbi` for `std::vec::Vec<[f32; 2]>`
error: aborting due to previous error
I did make some attempts, but still didn’t convert correctly.
So I want to know if this is feasible or if I have to serialize it？
Thank you very much!