Merge pull request #162 from skade/std-error

Have serde::de::Error require std::error::Error
This commit is contained in:
Erick Tryzelaar
2015-12-08 14:10:45 -05:00
8 changed files with 131 additions and 1 deletions
+18
View File
@@ -1,4 +1,6 @@
use test::Bencher;
use std::error;
use std::fmt;
use rustc_serialize::{Decoder, Decodable};
use serde;
use serde::de::{Deserializer, Deserialize};
@@ -29,6 +31,22 @@ impl serde::de::Error for Error {
fn missing_field(_: &'static str) -> Error { Error::SyntaxError }
}
impl fmt::Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
formatter.write_str(format!("{:?}", self).as_ref())
}
}
impl error::Error for Error {
fn description(&self) -> &str {
"Serde Deserialization Error"
}
fn cause(&self) -> Option<&error::Error> {
None
}
}
//////////////////////////////////////////////////////////////////////////////
mod decoder {