From 68e631c2997463f20049fbe8110362fe63c4eb17 Mon Sep 17 00:00:00 2001 From: Ayush <36449128+is-it-ayush@users.noreply.github.com> Date: Wed, 28 Feb 2024 18:41:03 +0530 Subject: [PATCH] chore: remove debug vals and add enum tests (#10) * chore: add enum tests * chore: remove debug --- Cargo.lock | 2 +- src/deserializer.rs | 11 ----------- src/lib.rs | 9 +++++++++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98e2b21..2fc8086 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,7 +150,7 @@ dependencies = [ [[package]] name = "rust-fr" -version = "0.1.0" +version = "1.0.0" dependencies = [ "bitvec", "ciborium", diff --git a/src/deserializer.rs b/src/deserializer.rs index c550b1e..9957c35 100644 --- a/src/deserializer.rs +++ b/src/deserializer.rs @@ -646,23 +646,17 @@ impl<'de, 'a> MapAccess<'de> for MapDeserializer<'a, 'de> { where K: serde::de::DeserializeSeed<'de>, { - println!("map(): key--start"); // if at end of map; exit if self.deserializer.peek_token(Delimiter::Map)? { - println!("map(): exit"); return Ok(None); } - println!("map(): key--loop"); // make not first; deserialize next key_1 self.first = false; let value = seed.deserialize(&mut *self.deserializer).map(Some)?; - println!("map(): deserialied_key"); if !self.deserializer.peek_token(Delimiter::MapKey)? { return Err(Error::ExpectedDelimiter(Delimiter::MapKey)); } - println!("map(): eating key delimiter"); self.deserializer.eat_token(Delimiter::MapKey)?; - println!("map(): key--end"); Ok(value) } @@ -674,16 +668,11 @@ impl<'de, 'a> MapAccess<'de> for MapDeserializer<'a, 'de> { where V: serde::de::DeserializeSeed<'de>, { - println!("map(): value--start"); - println!("peeking_map_value"); let value = seed.deserialize(&mut *self.deserializer)?; - println!("map(): deserialied_value"); if !self.deserializer.peek_token(Delimiter::MapValue)? { return Err(Error::ExpectedDelimiter(Delimiter::MapValue)); } - println!("map(): eating value delimiter"); self.deserializer.eat_token(Delimiter::MapValue)?; - println!("map(): value--end"); Ok(value) } } diff --git a/src/lib.rs b/src/lib.rs index 8bffdba..58a957b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,6 +88,14 @@ mod tests { c: Option, d: Option, e: Primitives, + f: Vec, + } + + #[derive(Debug, Serialize, Deserialize, PartialEq)] + enum AnEnum { + A(u8), + B { a: u8, b: u16 }, + C, } #[test] @@ -115,6 +123,7 @@ mod tests { l: 'a', m: "hello".to_string(), }, + f: vec![AnEnum::A(1), AnEnum::B { a: 1, b: 2 }, AnEnum::C], }; // Serialize