You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Later, in rustwasm/wasm-bindgen#3692@hillin asked why it wasn't possible to return a Vec<T> where T: IntoWasmAbi. I now have the exact same question. Unfortunately that issue was closed, and moved into this discussion rustwasm/wasm-bindgen#3697 where it received only one reply, from the question asker themself.
The answer was to create a newtype that itself is IntoWasmAbi and then return that:
The problem seems to be that tsify needs to implement the VectorIntoWasmAbi and WasmDescribeVector traits. These are the traits that allow converting a Vec<T> into a JS array of Ts.
Hello! Thanks for a great library!
In rustwasm/wasm-bindgen#3554 (See also: rustwasm/wasm-bindgen#111 ) the possibility to return a
Vec<SomeType>
whereSomeType
has#[wasm_bindgen]
on it was introduced.Later, in rustwasm/wasm-bindgen#3692 @hillin asked why it wasn't possible to return a
Vec<T>
whereT: IntoWasmAbi
. I now have the exact same question. Unfortunately that issue was closed, and moved into this discussion rustwasm/wasm-bindgen#3697 where it received only one reply, from the question asker themself.The answer was to create a newtype that itself is
IntoWasmAbi
and then return that:Which works, but now I have to have a number of newtypes that I don't want in my code.
I tried improving the situation by creating a generic version of that:
Which kind of half-worked - the TS type was correctly generated, but the return value of the function lacked the generic type argument:
So the question is, what's the solution here?
wasm-bindgen
to implement support forVec<T: IntoWasmAbi>
?tsify
to put the correct generic argument on the ts return type (i.e.getThings(): GenericCollection<Thing>;
)?The text was updated successfully, but these errors were encountered: