5

次のコードをコンパイルしたい。

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Dummy {}

#[wasm_bindgen]
pub fn test() -> Vec<Dummy> {
    vec![]
}

ただし、コンパイラはそれを許可しません。

error[E0277]: the trait bound `std::boxed::Box<[Dummy]>: wasm_bindgen::convert::traits::IntoWasmAbi` is not satisfied
  --> xxxx
   |
XX | #[wasm_bindgen]
   | ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::convert::traits::IntoWasmAbi` is not implemented for `std::boxed::Box<[Dummy]>`
   |
   = help: the following implementations were found:
             <std::boxed::Box<[f32]> as wasm_bindgen::convert::traits::IntoWasmAbi>
             <std::boxed::Box<[f64]> as wasm_bindgen::convert::traits::IntoWasmAbi>
             <std::boxed::Box<[i16]> as wasm_bindgen::convert::traits::IntoWasmAbi>
             <std::boxed::Box<[i32]> as wasm_bindgen::convert::traits::IntoWasmAbi>
           and 9 others
   = note: required because of the requirements on the impl of `wasm_bindgen::convert::traits::IntoWasmAbi` for `std::vec::Vec<Dummy>`

wasm_bindgen の最新バージョン (v0.2.55) を使用しています。これは可能だと思いますよね?

4

1 に答える 1