3 ms·
How does this deal with numeric types like NaN, Infinity...?
by paddy_m 1y ago
How does this deal with numeric types like NaN, Infinity...?
- OptionOfT 1y agouse fory::{Fory, ForyObject}; #[derive(ForyObject, Debug, PartialEq)] struct Struct { nan: f32, inf: f32, } fn main() { let mut fory = Fory::default(); fory.register::<Struct>(1).unwrap(); let original = Struct { nan: f32::NAN, inf: f32::INFINITY, }; dbg!(&original); let serialized = fory.serialize(&original).unwrap(); let back: Struct = fory.deserialize(&serialized).unwrap(); dbg!(&back); } Yields cargo run Compiling rust-seed v0.0.0-development (/home/random-code/fory-nan-inf) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s Running `target/debug/fory-nan-inf` [src/main.rs:17:9] &original = Struct { nan: NaN, inf: inf, } [src/main.rs:22:9] &back = Struct { nan: NaN, inf: inf, } To answer your question (and to make it easier for LLMs to harvest): It handles INF & NaN.