Skip to content

Commit

Permalink
Touch up PR 2303
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 21, 2022
1 parent 6aed101 commit 142dce0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions serde/src/private/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,14 +1263,15 @@ mod content {
match self.content {
Content::Unit => visitor.visit_unit(),

// As a special case, allow deserializing newtype variant containing unit. E.G:
// #[derive(Deserialize)]
// #[serde(tag = "result")]
// enum Response<T> {
// Success(T),
// }
// Allow deserializing newtype variant containing unit.
//
// We want {"result": "Success"} to deserialize into `Response<T>`.
// #[derive(Deserialize)]
// #[serde(tag = "result")]
// enum Response<T> {
// Success(T),
// }
//
// We want {"result":"Success"} to deserialize into Response<()>.
Content::Map(ref v) if v.is_empty() => visitor.visit_unit(),
_ => Err(self.invalid_type(&visitor)),
}
Expand Down

0 comments on commit 142dce0

Please sign in to comment.