From 211e2bb8d94ffa4b261d40492756cebd1923a861 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 4 Apr 2017 09:56:01 -0700 Subject: [PATCH] Support borrowed tokens in serde_test --- serde_test/src/de.rs | 2 ++ serde_test/src/token.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/serde_test/src/de.rs b/serde_test/src/de.rs index b2d6dd12..2ec45f46 100644 --- a/serde_test/src/de.rs +++ b/serde_test/src/de.rs @@ -105,8 +105,10 @@ impl<'de, 'a, I> de::Deserializer<'de> for &'a mut Deserializer 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), diff --git a/serde_test/src/token.rs b/serde_test/src/token.rs index 82ccd9f2..05e15583 100644 --- a/serde_test/src/token.rs +++ b/serde_test/src/token.rs @@ -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),