From 4fc124de9b7fe78582f7e9f0975d006f0c6a0d3b Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sat, 2 Aug 2014 09:25:44 -0700 Subject: [PATCH] Update to rust HEAD --- src/bench_enum.rs | 7 ++++++- src/bench_map.rs | 7 ++++++- src/bench_struct.rs | 7 ++++++- src/bench_vec.rs | 11 ++++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/bench_enum.rs b/src/bench_enum.rs index d276ec1e..7b20acdf 100644 --- a/src/bench_enum.rs +++ b/src/bench_enum.rs @@ -41,6 +41,7 @@ impl Deserializable for Animal { enum Error { EndOfStream, SyntaxError, + OtherError(String), } ////////////////////////////////////////////////////////////////////////////// @@ -48,7 +49,7 @@ enum Error { mod decoder { use serialize::Decoder; - use super::{Animal, Dog, Frog, Error, SyntaxError}; + use super::{Animal, Dog, Frog, Error, SyntaxError, OtherError}; enum State { AnimalState(Animal), @@ -73,6 +74,10 @@ mod decoder { } impl Decoder for AnimalDecoder { + fn error(&mut self, msg: &str) -> Error { + OtherError(msg.to_string()) + } + // Primitive types: fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) } fn read_uint(&mut self) -> Result { Err(SyntaxError) } diff --git a/src/bench_map.rs b/src/bench_map.rs index 63fb077b..d191930c 100644 --- a/src/bench_map.rs +++ b/src/bench_map.rs @@ -12,6 +12,7 @@ use de::{Deserializer, Deserializable}; enum Error { EndOfStream, SyntaxError, + OtherError(String), } ////////////////////////////////////////////////////////////////////////////// @@ -21,7 +22,7 @@ mod decoder { use std::collections::hashmap::MoveEntries; use serialize; - use super::{Error, EndOfStream, SyntaxError}; + use super::{Error, EndOfStream, SyntaxError, OtherError}; enum Value { StringValue(String), @@ -46,6 +47,10 @@ mod decoder { } impl serialize::Decoder for IntDecoder { + fn error(&mut self, msg: &str) -> Error { + OtherError(msg.to_string()) + } + // Primitive types: fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) } fn read_uint(&mut self) -> Result { Err(SyntaxError) } diff --git a/src/bench_struct.rs b/src/bench_struct.rs index 622dd4be..eec51861 100644 --- a/src/bench_struct.rs +++ b/src/bench_struct.rs @@ -120,13 +120,14 @@ impl Deserializable for Outer { enum Error { EndOfStream, SyntaxError, + OtherError(String), } mod decoder { use std::collections::HashMap; use serialize::Decoder; - use super::{Outer, Inner, Error, SyntaxError}; + use super::{Outer, Inner, Error, SyntaxError, OtherError}; #[deriving(Show)] enum State { @@ -157,6 +158,10 @@ mod decoder { } impl Decoder for OuterDecoder { + fn error(&mut self, msg: &str) -> Error { + OtherError(msg.to_string()) + } + // Primitive types: #[inline] fn read_nil(&mut self) -> Result<(), Error> { diff --git a/src/bench_vec.rs b/src/bench_vec.rs index bcf71fd9..39f2a795 100644 --- a/src/bench_vec.rs +++ b/src/bench_vec.rs @@ -11,6 +11,7 @@ use de::{Deserializer, Deserializable}; enum Error { EndOfStream, SyntaxError, + OtherError(String), } ////////////////////////////////////////////////////////////////////////////// @@ -19,7 +20,7 @@ mod decoder { use std::vec; use serialize; - use super::{Error, EndOfStream, SyntaxError}; + use super::{Error, EndOfStream, SyntaxError, OtherError}; pub struct IntDecoder { len: uint, @@ -37,6 +38,10 @@ mod decoder { } impl serialize::Decoder for IntDecoder { + fn error(&mut self, msg: &str) -> Error { + OtherError(msg.to_string()) + } + // Primitive types: fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) } fn read_uint(&mut self) -> Result { Err(SyntaxError) } @@ -138,6 +143,10 @@ mod decoder { } impl serialize::Decoder for U8Decoder { + fn error(&mut self, msg: &str) -> Error { + OtherError(msg.to_string()) + } + // Primitive types: fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) } fn read_uint(&mut self) -> Result { Err(SyntaxError) }