Skip to content

Commit efff77b

Browse files
ser: Add serialization suport for nan
Signed-off-by: Patrick José Pereira <[email protected]>
1 parent 65b2559 commit efff77b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/ser.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ where
173173
#[inline]
174174
fn serialize_f32(self, value: f32) -> Result<()> {
175175
match value.classify() {
176-
FpCategory::Nan | FpCategory::Infinite => {
176+
FpCategory::Nan => {
177+
tri!(self
178+
.formatter
179+
.write_number_str(&mut self.writer, "nan")
180+
.map_err(Error::io));
181+
}
182+
FpCategory::Infinite => {
177183
tri!(self
178184
.formatter
179185
.write_null(&mut self.writer)
@@ -192,7 +198,13 @@ where
192198
#[inline]
193199
fn serialize_f64(self, value: f64) -> Result<()> {
194200
match value.classify() {
195-
FpCategory::Nan | FpCategory::Infinite => {
201+
FpCategory::Nan => {
202+
tri!(self
203+
.formatter
204+
.write_number_str(&mut self.writer, "nan")
205+
.map_err(Error::io));
206+
}
207+
FpCategory::Infinite => {
196208
tri!(self
197209
.formatter
198210
.write_null(&mut self.writer)

0 commit comments

Comments
 (0)