Partial support for EnumStart in assert_ser_tokens

This commit is contained in:
David Tolnay 2017-04-05 01:15:42 -07:00
parent afaab12b66
commit 21adee8f40
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -149,7 +149,13 @@ impl<'s, 'a> ser::Serializer for &'s mut Serializer<'a> {
_variant_index: usize,
variant: &'static str)
-> Result<(), Error> {
if self.tokens.first() == Some(&Token::EnumStart(name)) {
self.next_token();
assert_next_token!(self, Str(variant));
assert_next_token!(self, Unit);
} else {
assert_next_token!(self, EnumUnit(name, variant));
}
Ok(())
}
@ -168,7 +174,12 @@ impl<'s, 'a> ser::Serializer for &'s mut Serializer<'a> {
-> Result<(), Error>
where T: Serialize
{
if self.tokens.first() == Some(&Token::EnumStart(name)) {
self.next_token();
assert_next_token!(self, Str(variant));
} else {
assert_next_token!(self, EnumNewType(name, variant));
}
value.serialize(self)
}