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
While crate is made for arithmetic, it is made for arbitrary precision arithmetic.
Now here's the thing, should the type for bnum be expressed as a number, a string, or some binary format.
The serde impl seems to serialize it as an array of limbs, but in most cases you'd probably want to serialize it as a string and parse it radix 10 or 16.
Personally, I'd express the type as string? Or should bigint be chosen here? (not sure if it's arbitrary precision?)
The text was updated successfully, but these errors were encountered:
Hey!
If we add an impl for it behind a bnum-impl feature gate, then that impl should be 1:1 compatible with their serde serialization. I think that's the only way that feature would be usefull for the average user.
If you're doing something special for serialization, you can use #[ts(type = "string")] or #[ts(as = "..")].
Our impls for large integer types (e.g u128) do currently use bigint, but it was a somewhat painfull tradeoff with them.
Serializing them as number would be serde-compatible by default, but probably wrong in almost all cases.
If I had the chance to go back and change it, I'd probably still chose number though. Then, it's serde-compatible, and when users chose a way of serializing them, they can also change the TS type using #[ts(type = "..")] or #[ts(as = "..")].
Is your feature request related to a problem? Please describe.
In my exploration in adopting
ts-rs
for TypeScript typegen in a project, I hit the roadblock of needing abnum
implementation.Describe the solution you'd like
An implementation for the
bnum
structs would be nice, but there is something to discuss here, which is why I opened an issue here first.First off, here's a link to the documentation of the crate: https://docs.rs/bnum/latest/bnum/
While crate is made for arithmetic, it is made for arbitrary precision arithmetic.
Now here's the thing, should the type for
bnum
be expressed as anumber
, astring
, or some binary format.The
serde
impl seems to serialize it as an array of limbs, but in most cases you'd probably want to serialize it as a string and parse it radix 10 or 16.Personally, I'd express the type as
string
? Or shouldbigint
be chosen here? (not sure if it's arbitrary precision?)The text was updated successfully, but these errors were encountered: