Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding serde support feature for Mpz #30

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

gbenattar
Copy link

We needed serde for Mpz in one of our upper layer (dependency). Here is a PR if you are interested, I added it as a feature.

cargo build --features "serde_support"
cargo test --features "serde_support"

Thanks,

@andersk
Copy link

andersk commented Aug 29, 2018

I’m not sure it makes sense as a global default to serialize to hexadecimal.

@gbenattar
Copy link
Author

Yes I agree. In my use case it ends up being serialized to JSON and propagated to an upper layer. Hex is good for readability. What would you suggest?

@andersk
Copy link

andersk commented Aug 29, 2018

At least Python and Java will happily serialize a big integer to JSON as an unquoted decimal number:

808017424794512875886459904961710757005754368000000000

which is perfectly fine as far as the JSON grammar is concerned, even though such values will not (yet?) round-trip through JavaScript. There is also a de facto convention of sending quoted decimal numbers where JavaScript interoperability is important:

"808017424794512875886459904961710757005754368000000000"

Twitter notably decided screw it, we’ll do both.

You can of course override the default behavior to whatever you want with a newtype wrapper, so the question here is what makes sense as a default.

I think unquoted decimal makes the most sense for Rust, which doesn’t have to worry about confusing big integers as approximate floats. Quoted decimal would be an understandable compromise if there are good reasons for it. But I don’t know of any widespread convention involving hexadecimal, and I’d find it especially strange to see hexadecimal without a 0x prefix.

@andersk
Copy link

andersk commented Mar 26, 2021

You made this PR from your master branch, which you are now using for unrelated commits. Time to close this PR?

This breaks existing projects that are dependent on this crate via git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants