Use question_mark feature in libserialize.
This commit is contained in:
parent
14d3937e65
commit
d73e374ddb
@ -475,15 +475,14 @@ pub fn new(writer: &'a mut fmt::Write) -> Encoder<'a> {
|
||||
}
|
||||
|
||||
macro_rules! emit_enquoted_if_mapkey {
|
||||
($enc:ident,$e:expr) => {
|
||||
($enc:ident,$e:expr) => ({
|
||||
if $enc.is_emitting_map_key {
|
||||
try!(write!($enc.writer, "\"{}\"", $e));
|
||||
Ok(())
|
||||
write!($enc.writer, "\"{}\"", $e)?;
|
||||
} else {
|
||||
try!(write!($enc.writer, "{}", $e));
|
||||
Ok(())
|
||||
write!($enc.writer, "{}", $e)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
impl<'a> ::Encoder for Encoder<'a> {
|
||||
|
@ -511,10 +511,10 @@ fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)*), D::Error> {
|
||||
let len: usize = count_idents!($($name,)*);
|
||||
d.read_tuple(len, |d| {
|
||||
let mut i = 0;
|
||||
let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 },
|
||||
|d| -> Result<$name,D::Error> {
|
||||
let ret = ($(d.read_tuple_arg({ i+=1; i-1 },
|
||||
|d| -> Result<$name,D::Error> {
|
||||
Decodable::decode(d)
|
||||
})),)*);
|
||||
})?,)*);
|
||||
Ok(ret)
|
||||
})
|
||||
}
|
||||
@ -527,7 +527,7 @@ fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
$(let $name = $name; n += 1;)*
|
||||
s.emit_tuple(n, |s| {
|
||||
let mut i = 0;
|
||||
$(try!(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s)));)*
|
||||
$(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s))?;)*
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user