From 23c14e5f335107bde3e14aadfadc118243e5fae3 Mon Sep 17 00:00:00 2001 From: Mingun Date: Thu, 22 Oct 2020 23:50:48 +0500 Subject: [PATCH] Allow to run assert_de_tokens_error on token sequence that is not expected by enum deserializer Before that fix following code panics, because `Token::Unit` was unexpected by test deserializer: ``` #[derive(Deserialize)] enum E { ... } assert_de_tokens_error::(&[Token::Unit], "..."); ``` --- serde_test/src/de.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/serde_test/src/de.rs b/serde_test/src/de.rs index c9bcee5b..a1d62758 100644 --- a/serde_test/src/de.rs +++ b/serde_test/src/de.rs @@ -250,9 +250,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { { visitor.visit_enum(DeserializerEnumVisitor { de: self }) } - _ => { - unexpected!(self.next_token()); - } + _ => self.deserialize_any(visitor) } }