Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove debug vals and add enum tests #10

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}
}
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ mod tests {
c: Option<u8>,
d: Option<String>,
e: Primitives,
f: Vec<AnEnum>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
enum AnEnum {
A(u8),
B { a: u8, b: u16 },
C,
}

#[test]
Expand Down Expand Up @@ -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
Expand Down
Loading