Support borrowed tokens in serde_test

This commit is contained in:
David Tolnay 2017-04-04 09:56:01 -07:00
parent cee3efbda8
commit 211e2bb8d9
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 8 additions and 0 deletions

View File

@ -105,8 +105,10 @@ impl<'de, 'a, I> de::Deserializer<'de> for &'a mut Deserializer<I>
Some(Token::F64(v)) => visitor.visit_f64(v),
Some(Token::Char(v)) => visitor.visit_char(v),
Some(Token::Str(v)) => visitor.visit_str(v),
Some(Token::BorrowedStr(v)) => visitor.visit_borrowed_str(v),
Some(Token::String(v)) => visitor.visit_string(v),
Some(Token::Bytes(v)) => visitor.visit_bytes(v),
Some(Token::BorrowedBytes(v)) => visitor.visit_borrowed_bytes(v),
Some(Token::ByteBuf(v)) => visitor.visit_byte_buf(v),
Some(Token::Option(false)) => visitor.visit_none(),
Some(Token::Option(true)) => visitor.visit_some(self),

View File

@ -39,12 +39,18 @@ pub enum Token<'a> {
/// A serialized `str`.
Str(&'a str),
/// A borrowed `str`.
BorrowedStr(&'a str),
/// A serialized `String`.
String(String),
/// A serialized `[u8]`
Bytes(&'a [u8]),
/// A borrowed `[u8]`.
BorrowedBytes(&'a [u8]),
/// A serialized `ByteBuf`
ByteBuf(Vec<u8>),