diff options
author | daubaris <paulius.daubaris@gmail.com> | 2019-11-22 18:28:29 +0200 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2019-11-22 10:28:29 -0600 |
commit | 60b874308e6792a73cc00517a60bbef60a12e3cc (patch) | |
tree | 3fac2b54902d2a40462ece80aff2bdefcfe05558 /src/de.rs | |
parent | 75129040cd041b380f4f1d8f2685928392aa9f55 (diff) | |
download | milf-rs-60b874308e6792a73cc00517a60bbef60a12e3cc.tar.gz milf-rs-60b874308e6792a73cc00517a60bbef60a12e3cc.zip |
Mixed type arrays (#358)
* Added support of mixed-type arrays
* Add tests cases
* Replaced &'static str type for type_ and created a new enum instead
* Restored ArrayMixedType
Diffstat (limited to 'src/de.rs')
-rw-r--r-- | src/de.rs | 19 |
1 files changed, 0 insertions, 19 deletions
@@ -11,7 +11,6 @@ use std::f64; use std::fmt; use std::iter; use std::marker::PhantomData; -use std::mem::discriminant; use std::str; use std::vec; @@ -147,10 +146,6 @@ enum ErrorKind { found: &'static str, }, - /// An array was decoded but the types inside of it were mixed, which is - /// disallowed by TOML. - MixedArrayType, - /// A duplicate table definition was found. DuplicateTable(String), @@ -1827,13 +1822,7 @@ impl<'a> Deserializer<'a> { if let Some(span) = self.eat_spanned(Token::RightBracket)? { return Ok((span, ret)); } - let at = self.tokens.current(); let value = self.value()?; - if let Some(last) = ret.last() { - if !value.same_type(last) { - return Err(self.error(at, ErrorKind::MixedArrayType)); - } - } ret.push(value); intermediate(self)?; if !self.eat(Token::Comma)? { @@ -2118,7 +2107,6 @@ impl fmt::Display for Error { } ErrorKind::NumberInvalid => "invalid number".fmt(f)?, ErrorKind::DateInvalid => "invalid date".fmt(f)?, - ErrorKind::MixedArrayType => "mixed types in an array".fmt(f)?, ErrorKind::DuplicateTable(ref s) => { write!(f, "redefinition of table `{}`", s)?; } @@ -2180,7 +2168,6 @@ impl error::Error for Error { ErrorKind::Wanted { .. } => "expected a token but found another", ErrorKind::NumberInvalid => "invalid number", ErrorKind::DateInvalid => "invalid date", - ErrorKind::MixedArrayType => "mixed types in an array", ErrorKind::DuplicateTable(_) => "duplicate table", ErrorKind::RedefineAsArray => "table redefined as array", ErrorKind::EmptyTableKey => "empty table key found", @@ -2283,9 +2270,3 @@ impl<'a> E<'a> { } } } - -impl<'a> Value<'a> { - fn same_type(&self, other: &Value<'a>) -> bool { - discriminant(&self.e) == discriminant(&other.e) - } -} |