From 142dce0d3dc82f59f1a06342864de51160b12c65 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 21 Oct 2022 01:02:46 -0700 Subject: [PATCH] Touch up PR 2303 --- serde/src/private/de.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index 7cb540c14..01e5bf787 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -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 { - // Success(T), - // } + // Allow deserializing newtype variant containing unit. // - // We want {"result": "Success"} to deserialize into `Response`. + // #[derive(Deserialize)] + // #[serde(tag = "result")] + // enum Response { + // 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)), }