Skip to content

Commit

Permalink
Consistently use visit_content_seq and visit_content_map when deseria…
Browse files Browse the repository at this point in the history
…lize enums

Helper methods visit_content_[seq|map] does the same as [Seq|Map]Deserializer::deserialize_any
and used everywhere except here. Reuse them for consistency
  • Loading branch information
Mingun committed Aug 24, 2024
1 parent 508ec36 commit 36266bd
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions serde/src/private/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1615,9 +1615,7 @@ mod content {
V: de::Visitor<'de>,
{
match self.value {
Some(Content::Seq(v)) => {
de::Deserializer::deserialize_any(SeqDeserializer::new(v.into_iter()), visitor)
}
Some(Content::Seq(v)) => visit_content_seq(v, visitor),
Some(other) => Err(de::Error::invalid_type(
other.unexpected(),
&"tuple variant",
Expand All @@ -1638,12 +1636,8 @@ mod content {
V: de::Visitor<'de>,
{
match self.value {
Some(Content::Map(v)) => {
de::Deserializer::deserialize_any(MapDeserializer::new(v.into_iter()), visitor)
}
Some(Content::Seq(v)) => {
de::Deserializer::deserialize_any(SeqDeserializer::new(v.into_iter()), visitor)
}
Some(Content::Map(v)) => visit_content_map(v, visitor),
Some(Content::Seq(v)) => visit_content_seq(v, visitor),
Some(other) => Err(de::Error::invalid_type(
other.unexpected(),
&"struct variant",
Expand Down

0 comments on commit 36266bd

Please sign in to comment.