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
As someone who has recently learned wasm-bindgen, something that keeps bothering me is that OptionFromWasmAbi, OptionIntoWasmAbi wont get implemented for struct, and I always need to work around that.
for example let's say there is some struct:
#[wasm-bindgen]pubstructSomeStruct;
and when using that as an argument of some fn, there is no issue with having that as either of Option<SomeStruct> or &SomeStruct, but when using it as Option<&SomeStruct> there are compiler complaints.
the trait bound &SomeStruct: OptionFromWasmAbi is not satisfied
the trait OptionFromWasmAbi is implemented for SomeStruct
required for std::option::Option<&SomeStruct> to implement FromWasmAbi
having that can be usefull in cases where we dont want/need the ownership to be transfered to the underlying function and also want to keep that argument as an Option
Proposed Solution
As I stated earlier Im pretty new to wasm-bindgen, so there might be some easy workaround/solution for this out there already, if so, it would be great that someone can point it out here so someone like me and possibly others can benefit from, but as far asI searched I could not find any standard solution for this.
The text was updated successfully, but these errors were encountered:
Motivation
As someone who has recently learned wasm-bindgen, something that keeps bothering me is that
OptionFromWasmAbi
,OptionIntoWasmAbi
wont get implemented for struct, and I always need to work around that.for example let's say there is some struct:
and when using that as an argument of some fn, there is no issue with having that as either of
Option<SomeStruct>
or&SomeStruct
, but when using it asOption<&SomeStruct>
there are compiler complaints.with this error:
the trait bound
&SomeStruct: OptionFromWasmAbi
is not satisfiedthe trait
OptionFromWasmAbi
is implemented forSomeStruct
required for
std::option::Option<&SomeStruct>
to implementFromWasmAbi
having that can be usefull in cases where we dont want/need the ownership to be transfered to the underlying function and also want to keep that argument as an Option
Proposed Solution
As I stated earlier Im pretty new to wasm-bindgen, so there might be some easy workaround/solution for this out there already, if so, it would be great that someone can point it out here so someone like me and possibly others can benefit from, but as far asI searched I could not find any standard solution for this.
The text was updated successfully, but these errors were encountered: