Skip to content

Commit ba64e95

Browse files
committed
cargo fmt
1 parent 5ccffa1 commit ba64e95

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/de/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Deserialize JSON data to a Rust data structure
22
3-
use core::{fmt, str};
43
use core::str::FromStr;
4+
use core::{fmt, str};
55

66
use serde::de::{self, Visitor};
77

@@ -286,13 +286,14 @@ macro_rules! deserialize_fromstr {
286286
if $pattern.iter().find(|&&d| d == c).is_some() {
287287
$self.eat_char();
288288
} else {
289-
let s = unsafe { // already checked that it contains only ascii
289+
let s = unsafe {
290+
// already checked that it contains only ascii
290291
str::from_utf8_unchecked(&$self.slice[start..$self.index])
291292
};
292293
let v = $typ::from_str(s).or(Err(Error::InvalidNumber))?;
293294
return $visitor.$visit_fn(v);
294295
}
295-
},
296+
}
296297
None => return Err(Error::EofWhileParsingNumber),
297298
}
298299
}
@@ -758,7 +759,9 @@ mod tests {
758759

759760
assert_eq!(
760761
crate::from_str(r#"{ "temperature": -2.1e-3 }"#),
761-
Ok(Temperature { temperature: -2.1e-3 })
762+
Ok(Temperature {
763+
temperature: -2.1e-3
764+
})
762765
);
763766

764767
assert_eq!(
@@ -770,7 +773,9 @@ mod tests {
770773

771774
assert_eq!(
772775
crate::from_str(r#"{ "temperature": -1e500 }"#),
773-
Ok(Temperature { temperature: f32::NEG_INFINITY })
776+
Ok(Temperature {
777+
temperature: f32::NEG_INFINITY
778+
})
774779
);
775780

776781
assert!(crate::from_str::<Temperature>(r#"{ "temperature": 1e1e1 }"#).is_err());

src/ser/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::{fmt, fmt::Write};
44

55
use serde::ser;
66

7-
use heapless::{String, Vec, consts::*};
7+
use heapless::{consts::*, String, Vec};
88

99
use self::seq::SerializeSeq;
1010
use self::struct_::SerializeStruct;
@@ -524,18 +524,22 @@ mod tests {
524524
);
525525

526526
assert_eq!(
527-
&*crate::to_string::<N, _>(&Temperature { temperature: -20345. }).unwrap(),
527+
&*crate::to_string::<N, _>(&Temperature {
528+
temperature: -20345.
529+
})
530+
.unwrap(),
528531
r#"{"temperature":-2.0345e4}"#
529532
);
530533

531534
assert_eq!(
532-
&*crate::to_string::<N, _>(&Temperature { temperature: -2.3456789012345e-23 }).unwrap(),
535+
&*crate::to_string::<N, _>(&Temperature {
536+
temperature: -2.3456789012345e-23
537+
})
538+
.unwrap(),
533539
r#"{"temperature":-2.3456788e-23}"#
534540
);
535-
536541
}
537542

538-
539543
#[test]
540544
fn struct_option() {
541545
#[derive(Serialize)]

0 commit comments

Comments
 (0)