Have serde::de::Error require std::error::Error

This commit is contained in:
Florian Gilcher
2015-09-24 07:03:36 -07:00
parent a1bd0c1667
commit fc19895237
8 changed files with 131 additions and 1 deletions
+18
View File
@@ -1,5 +1,7 @@
use std::collections::HashMap;
use test::Bencher;
use std::fmt;
use std::error;
use rustc_serialize::{Decoder, Decodable};
@@ -44,6 +46,22 @@ impl serde::de::Error for Error {
}
}
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 {
use std::collections::HashMap;
use rustc_serialize::Decoder;