-
Notifications
You must be signed in to change notification settings - Fork 132
f64::INFINITY causes panic #159
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
Comments
@kvark Any idea how to handle this? Should we support infinity at all? |
Right now, it serializes to Code to use for the integration test (in case this gets implemented): use std::f64;
use ron::{de, ser};
use serde::*;
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Test1 {
field: f64,
}
#[test]
fn roundtrip_infinity() {
let original = Test1 {
field: f64::INFINITY,
};
let pretty: ser::PrettyConfig = Default::default();
let serialized = ser::to_string_pretty(&original, pretty.clone()).unwrap();
println!("serialized: {}", serialized);
let duplicate: Test1 = de::from_str(&serialized).unwrap();
assert_eq!(original, duplicate);
} |
@torkleyy sounds like we need special ser/deser for "inf" and "-inf". |
@kvark @torkleyy I'd suggest making sure that RON can handle all possible floating point values; I'm not too sure what your goals for RON are, but as an end user RON sounds like python pickle, but for rust. In short, as an end user I kind of expect RON to be able to handle absolutely everything that rust can throw at it, unless there is an explicit marking that the thing can't be serialized for some reason (and I expect that to happen via serde, not via RON panicking). |
@ckaran thanks for the advice. It sounds good to me to follow. |
163: Implement inf, -inf and NaN handling r=torkleyy a=artemshein FIxes #159 Co-authored-by: Artem Shein <[email protected]>
163: Implement inf, -inf and NaN handling r=torkleyy a=artemshein FIxes #159 Co-authored-by: Artem Shein <[email protected]>
Problem summary
I need to be able to serialize and deserialize
f64::INFINITY
in my code. I believe that this should be possible, but the following code causes a panic when run:There is no panic for finite
f64
values.The panic:
Meta information:
The text was updated successfully, but these errors were encountered: