From f967a77a80c8eed8967dfbae4aa3dcb3909e2558 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 14 Aug 2014 19:08:41 -0700 Subject: [PATCH] add tests to deserializing sequences into a tuple --- src/de.rs | 4 ++-- src/json/mod.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/de.rs b/src/de.rs index b96fb541..37ec3556 100644 --- a/src/de.rs +++ b/src/de.rs @@ -199,13 +199,13 @@ pub trait Deserializer: Iterator> { fn expect_null(&mut self, token: Token) -> Result<(), E> { match token { Null => Ok(()), - TupleStart(_) => { + TupleStart(_) | SeqStart(_) => { match try!(self.expect_token()) { End => Ok(()), token => Err(self.syntax_error(token, [EndKind])), } } - token => Err(self.syntax_error(token, [NullKind, TupleStartKind])), + token => Err(self.syntax_error(token, [NullKind, TupleStartKind, SeqStartKind])), } } diff --git a/src/json/mod.rs b/src/json/mod.rs index 39ee9fe9..bddf101f 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -2897,6 +2897,13 @@ mod tests { test_parse_ok([ ("[[3], [1, 2]]", vec!(vec!(3i), vec!(1, 2))), ]); + + let v: () = from_iter("[]".chars()).unwrap(); + assert_eq!(v, ()); + + test_parse_ok([ + ("[1, 2, 3]", (1u, 2u, 3u)), + ]); } #[test]