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
With serde-wasm-bindgen conversion between bigint and u64 is unproblematic. When I have a struct with a u64 in Rust, I get a bigint (or BigInt) in JS-land. With gloo-utilsu64 is translated to number, losing precision.
Without knowing how the library really works, I'm guessing the u64 gets stringified Rust-side into a neat { field: 12815844532926915242 } and then JSON.parse() mangles that value. I'm not sure this scenario can be handled with this approach at all. In that case, using serde-wasm-bindgen works well, and should be used instead.
The only way to make this work, I guess, is to treat the number as a string and then transparently post-process it in JS. I'm not sure this within the scope of your project. If it isn't, feel free to close this issue!
The text was updated successfully, but these errors were encountered:
Describe the Bug
With
serde-wasm-bindgen
conversion between bigint and u64 is unproblematic. When I have astruct
with au64
in Rust, I get abigint
(orBigInt
) in JS-land. Withgloo-utils
u64
is translated tonumber
, losing precision.Steps to Reproduce
Rust:
Then in JS:
Expected Behavior
Actual Behavior
Result:
And 12815844532926915000 ≠ 12815844532926915242.
Additional Context
Without knowing how the library really works, I'm guessing the
u64
gets stringified Rust-side into a neat{ field: 12815844532926915242 }
and thenJSON.parse()
mangles that value. I'm not sure this scenario can be handled with this approach at all. In that case, usingserde-wasm-bindgen
works well, and should be used instead.The only way to make this work, I guess, is to treat the number as a string and then transparently post-process it in JS. I'm not sure this within the scope of your project. If it isn't, feel free to close this issue!
The text was updated successfully, but these errors were encountered: