From 4c151fce3bd69c0101226437b52fcc46d38e2be9 Mon Sep 17 00:00:00 2001 From: Martin Bartlett Date: Mon, 28 Oct 2024 15:39:17 +0100 Subject: [PATCH] cargo fmt --- src/error.rs | 8 +++++--- src/lib.rs | 33 ++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/error.rs b/src/error.rs index eb38cec4..72d5ff45 100644 --- a/src/error.rs +++ b/src/error.rs @@ -213,7 +213,7 @@ impl Error { match &self.error { ErrorType::Io(_) | ErrorType::InputTooLarge => true, ErrorType::InternalError(e) if !matches!(e, crate::InternalError::TapeError) => true, - _ => false + _ => false, } } @@ -234,7 +234,8 @@ impl Error { #[must_use] pub fn is_syntax(&self) -> bool { // Lazy? maybe but if it aint something else... - matches!(self.error, + matches!( + self.error, ErrorType::InternalError(crate::InternalError::TapeError) | //This seems to get thrown on some syntax errors ErrorType::BadKeyType | ErrorType::ExpectedArrayComma | @@ -258,7 +259,8 @@ impl Error { ErrorType::ExpectedObjectContent | ErrorType::ExpectedObjectKey | ErrorType::Overflow | - ErrorType::SimdUnsupported) + ErrorType::SimdUnsupported + ) } } impl std::error::Error for Error {} diff --git a/src/lib.rs b/src/lib.rs index 37f2e42d..4398d22e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1090,8 +1090,8 @@ impl DerefMut for AlignedBuf { #[cfg(test)] mod tests { - use serde_ext::Deserialize; use crate::Deserializer; + use serde_ext::Deserialize; static JSON: &str = r#"{ "code": 200, @@ -1106,14 +1106,14 @@ mod tests { #[derive(Deserialize, PartialEq, Debug)] struct TestPayload { - features: Vec + features: Vec, } #[derive(Deserialize, PartialEq, Debug)] struct TestEnvelope { code: usize, success: bool, - payload: TestPayload + payload: TestPayload, } #[test] @@ -1135,11 +1135,18 @@ mod tests { // proving that value peeking doesn't affect the deserializer - assert_eq!(original_index, d.idx, "Deserializer has been internally modified"); - assert_eq!(original_nodes, d.tape.len(), "Deserializer has been internally modified"); + assert_eq!( + original_index, d.idx, + "Deserializer has been internally modified" + ); + assert_eq!( + original_nodes, + d.tape.len(), + "Deserializer has been internally modified" + ); } - #[test] + #[test] fn test_deser_restart() { let mut json = JSON.as_bytes().to_vec(); let mut d = Deserializer::from_slice(&mut json).expect("Invalid JSON"); @@ -1149,12 +1156,20 @@ mod tests { let test1 = TestEnvelope::deserialize(&mut d).expect("Deserialization failed"); - assert!(original_index != d.idx, "Deserializer has NOT been internally modified"); - assert_eq!(original_nodes, d.tape.len(), "Deserializer nodes are NOT intact"); + assert!( + original_index != d.idx, + "Deserializer has NOT been internally modified" + ); + assert_eq!( + original_nodes, + d.tape.len(), + "Deserializer nodes are NOT intact" + ); d.restart(); let test2 = TestEnvelope::deserialize(&mut d).expect("Deserialization failed"); assert_eq!(test2, test1, "Deserializer is not idempotent"); - }} + } +}