-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support Serialize
+ Deserialize
for dashu-ratio
#20
Conversation
rational/src/third_party/ser.rs
Outdated
serializer.serialize_str(&self.to_string()) | ||
} else { | ||
let sign = self.sign(); | ||
let numerator = self.numerator().clone().into_parts().1.to_le_bytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more clone here, because the slice cannot be obtained directly
Well, sorry, seems not work with |
Thanks for your contribution, but the implementation seems over-complicate for me. Do you have any specific reason to serialize the rational number as a struct with three parts? I was planning to serialize the rational number just as a pair of integers. Besides, you can take a look at #11, where I listed all thirdparty crates I planned to support, so you don't have to implement them yourselves. |
How about dividing into the following three binary representations?
|
I don't think we need to handle the VLQ implementation ourselves, it could be handled by serializers like the What I have planned for the (binary) serialization formats is:
For text serialization, I would just use the format result of each type. |
Thanks for your help but I will close this issue for now. |
"-5/11"