aboutsummaryrefslogtreecommitdiff
path: root/src/decoder
diff options
context:
space:
mode:
authorAndrzej Janik <vosen@vosen.pl>2015-06-04 20:23:46 +0200
committerAndrzej Janik <vosen@vosen.pl>2015-06-04 20:23:46 +0200
commit2fcd829b1d9c70d0981411b4f4adca9124985b54 (patch)
tree1487d67764c99542b6fc7df30c60dc89719dd370 /src/decoder
parent971700148b58df921f070015febd8706c66edded (diff)
downloadmilf-rs-2fcd829b1d9c70d0981411b4f4adca9124985b54.tar.gz
milf-rs-2fcd829b1d9c70d0981411b4f4adca9124985b54.zip
Disallow table redefinitions
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/rustc_serialize.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/decoder/rustc_serialize.rs b/src/decoder/rustc_serialize.rs
index 6e8fe59..af38f9b 100644
--- a/src/decoder/rustc_serialize.rs
+++ b/src/decoder/rustc_serialize.rs
@@ -3,7 +3,7 @@ use std::mem;
use super::{Decoder, DecodeError};
use super::DecodeErrorKind::*;
-use Value;
+use {Value, Table};
impl rustc_serialize::Decoder for Decoder {
type Error = DecodeError;
@@ -141,7 +141,7 @@ impl rustc_serialize::Decoder for Decoder {
Some(Value::Table(..)) => {
let ret = try!(f(self));
match self.toml {
- Some(Value::Table(ref t)) if t.len() == 0 => {}
+ Some(Value::Table(Table(ref t, _,))) if t.len() == 0 => {}
_ => return Ok(ret)
}
self.toml.take();
@@ -156,7 +156,7 @@ impl rustc_serialize::Decoder for Decoder {
{
let field = format!("{}", f_name);
let toml = match self.toml {
- Some(Value::Table(ref mut table)) => {
+ Some(Value::Table(Table(ref mut table, _))) => {
table.remove(&field)
.or_else(|| table.remove(&f_name.replace("_", "-")))
},
@@ -165,7 +165,7 @@ impl rustc_serialize::Decoder for Decoder {
let mut d = self.sub_decoder(toml, f_name);
let ret = try!(f(&mut d));
if let Some(value) = d.toml {
- if let Some(Value::Table(ref mut table)) = self.toml {
+ if let Some(Value::Table(Table(ref mut table, _))) = self.toml {
table.insert(field, value);
}
}
@@ -260,7 +260,7 @@ impl rustc_serialize::Decoder for Decoder {
where F: FnOnce(&mut Decoder, usize) -> Result<T, DecodeError>
{
let len = match self.toml {
- Some(Value::Table(ref table)) => table.len(),
+ Some(Value::Table(Table(ref table, _))) => table.len(),
ref found => return Err(self.mismatch("table", found)),
};
let ret = try!(f(self, len));
@@ -273,7 +273,7 @@ impl rustc_serialize::Decoder for Decoder {
{
match self.toml {
Some(Value::Table(ref table)) => {
- match table.iter().skip(idx).next() {
+ match table.0.iter().skip(idx).next() {
Some((key, _)) => {
let val = Value::String(format!("{}", key));
f(&mut self.sub_decoder(Some(val), &**key))
@@ -290,7 +290,7 @@ impl rustc_serialize::Decoder for Decoder {
{
match self.toml {
Some(Value::Table(ref table)) => {
- match table.iter().skip(idx).next() {
+ match table.0.iter().skip(idx).next() {
Some((_, value)) => {
// XXX: this shouldn't clone
f(&mut self.sub_decoder(Some(value.clone()), ""))