Get serde feature compiling again

This commit is contained in:
Erick Tryzelaar 2015-08-12 23:01:49 -07:00
parent 4e0172a9a5
commit bbc167cde9
2 changed files with 10 additions and 10 deletions

View file

@ -12,8 +12,8 @@ struct MapVisitor<'a, I> {
fn se2toml(err: de::value::Error, ty: &'static str) -> DecodeError { fn se2toml(err: de::value::Error, ty: &'static str) -> DecodeError {
match err { match err {
de::value::Error::SyntaxError => de::Error::syntax_error(), de::value::Error::SyntaxError => de::Error::syntax(ty),
de::value::Error::EndOfStreamError => de::Error::end_of_stream_error(), de::value::Error::EndOfStreamError => de::Error::end_of_stream(),
de::value::Error::MissingFieldError(s) => { de::value::Error::MissingFieldError(s) => {
DecodeError { DecodeError {
field: Some(s.to_string()), field: Some(s.to_string()),
@ -64,7 +64,7 @@ impl de::Deserializer for Decoder {
value: None, value: None,
}) })
} }
None => Err(de::Error::end_of_stream_error()), None => Err(de::Error::end_of_stream()),
} }
} }
@ -155,7 +155,7 @@ impl<'a, I> de::SeqVisitor for SeqDeserializer<'a, I>
if self.len == 0 { if self.len == 0 {
Ok(()) Ok(())
} else { } else {
Err(de::Error::end_of_stream_error()) Err(de::Error::end_of_stream())
} }
} }
@ -165,19 +165,19 @@ impl<'a, I> de::SeqVisitor for SeqDeserializer<'a, I>
} }
impl de::Error for DecodeError { impl de::Error for DecodeError {
fn syntax_error() -> DecodeError { fn syntax(_: &str) -> DecodeError {
DecodeError { field: None, kind: DecodeErrorKind::SyntaxError } DecodeError { field: None, kind: DecodeErrorKind::SyntaxError }
} }
fn end_of_stream_error() -> DecodeError { fn end_of_stream() -> DecodeError {
DecodeError { field: None, kind: DecodeErrorKind::EndOfStream } DecodeError { field: None, kind: DecodeErrorKind::EndOfStream }
} }
fn missing_field_error(name: &'static str) -> DecodeError { fn missing_field(name: &'static str) -> DecodeError {
DecodeError { DecodeError {
field: Some(name.to_string()), field: Some(name.to_string()),
kind: DecodeErrorKind::ExpectedField(None), kind: DecodeErrorKind::ExpectedField(None),
} }
} }
fn unknown_field_error(name: &str) -> DecodeError { fn unknown_field(name: &str) -> DecodeError {
DecodeError { DecodeError {
field: Some(name.to_string()), field: Some(name.to_string()),
kind: DecodeErrorKind::UnknownField, kind: DecodeErrorKind::UnknownField,
@ -239,7 +239,7 @@ impl<'a, I> de::MapVisitor for MapVisitor<'a, I>
} }
Ok(v) Ok(v)
}, },
None => Err(de::Error::end_of_stream_error()) None => Err(de::Error::end_of_stream())
} }
} }

View file

@ -87,7 +87,7 @@ fn application_decode_error() {
fn deserialize<D: Deserializer>(d: &mut D) -> Result<Range10, D::Error> { fn deserialize<D: Deserializer>(d: &mut D) -> Result<Range10, D::Error> {
let x: usize = try!(Deserialize::deserialize(d)); let x: usize = try!(Deserialize::deserialize(d));
if x > 10 { if x > 10 {
Err(serde::de::Error::syntax_error()) Err(serde::de::Error::syntax("more than 10"))
} else { } else {
Ok(Range10(x)) Ok(Range10(x))
} }