diff options
author | Alex Crichton <alex@alexcrichton.com> | 2017-03-31 18:45:00 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2017-03-31 18:45:00 -0700 |
commit | 827a7c960cdfc6285afa5d780a6c0e273019ea09 (patch) | |
tree | d538ae7dd77afd8d5ba7b62c1838c6a7c0630f76 | |
parent | 290973410b8519f1850a0faf98e9028e25d50510 (diff) | |
download | milf-rs-827a7c960cdfc6285afa5d780a6c0e273019ea09.tar.gz milf-rs-827a7c960cdfc6285afa5d780a6c0e273019ea09.zip |
Fix backcompat with array definitions
-rw-r--r-- | src/de.rs | 7 | ||||
-rw-r--r-- | tests/backcompat.rs | 9 |
2 files changed, 13 insertions, 3 deletions
@@ -634,7 +634,12 @@ impl<'a> Deserializer<'a> { } else { loop { match self.next()? { - Some(Token::RightBracket) | + Some(Token::RightBracket) => { + if array { + self.eat(Token::RightBracket)?; + } + break + } Some(Token::Newline) | None => break, _ => {} diff --git a/tests/backcompat.rs b/tests/backcompat.rs index 33dbfa5..1b3f599 100644 --- a/tests/backcompat.rs +++ b/tests/backcompat.rs @@ -5,10 +5,15 @@ use serde::de::Deserialize; #[test] fn main() { - assert!("[a] foo = 1".parse::<toml::Value>().is_err()); + let s = " + [a] foo = 1 + [[b]] foo = 1 + "; + assert!(s.parse::<toml::Value>().is_err()); - let mut d = toml::de::Deserializer::new("[a] foo = 1"); + let mut d = toml::de::Deserializer::new(s); d.set_require_newline_after_table(false); let value = toml::Value::deserialize(&mut d).unwrap(); assert_eq!(value["a"]["foo"].as_integer(), Some(1)); + assert_eq!(value["b"][0]["foo"].as_integer(), Some(1)); } |