diff options
Diffstat (limited to 'src/libserialize')
| -rw-r--r-- | src/libserialize/base64.rs | 2 | ||||
| -rw-r--r-- | src/libserialize/json.rs | 42 | ||||
| -rw-r--r-- | src/libserialize/serialize.rs | 10 |
3 files changed, 28 insertions, 26 deletions
diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 59faf75c0c3..8ded963b928 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -385,7 +385,7 @@ mod tests { #[test] fn test_from_base64_invalid_char() { - assert!("Zm$=".from_base64().is_err()) + assert!("Zm$=".from_base64().is_err()); assert!("Zg==$".from_base64().is_err()); } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index c811a16e2b1..e7b2d0c8eba 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1970,7 +1970,7 @@ impl Decoder { } } -macro_rules! expect( +macro_rules! expect { ($e:expr, Null) => ({ match $e { Json::Null => Ok(()), @@ -1987,7 +1987,7 @@ macro_rules! expect( } } }) -) +} macro_rules! read_primitive { ($name:ident, $ty:ty) => { @@ -2020,16 +2020,16 @@ impl ::Decoder<DecoderError> for Decoder { expect!(self.pop(), Null) } - read_primitive!(read_uint, uint) - read_primitive!(read_u8, u8) - read_primitive!(read_u16, u16) - read_primitive!(read_u32, u32) - read_primitive!(read_u64, u64) - read_primitive!(read_int, int) - read_primitive!(read_i8, i8) - read_primitive!(read_i16, i16) - read_primitive!(read_i32, i32) - read_primitive!(read_i64, i64) + read_primitive! { read_uint, uint } + read_primitive! { read_u8, u8 } + read_primitive! { read_u16, u16 } + read_primitive! { read_u32, u32 } + read_primitive! { read_u64, u64 } + read_primitive! { read_int, int } + read_primitive! { read_i8, i8 } + read_primitive! { read_i16, i16 } + read_primitive! { read_i32, i32 } + read_primitive! { read_i64, i64 } fn read_f32(&mut self) -> DecodeResult<f32> { self.read_f64().map(|x| x as f32) } @@ -2298,25 +2298,25 @@ pub trait ToJson for Sized? { fn to_json(&self) -> Json; } -macro_rules! to_json_impl_i64( +macro_rules! to_json_impl_i64 { ($($t:ty), +) => ( $(impl ToJson for $t { fn to_json(&self) -> Json { Json::I64(*self as i64) } })+ ) -) +} -to_json_impl_i64!(int, i8, i16, i32, i64) +to_json_impl_i64! { int, i8, i16, i32, i64 } -macro_rules! to_json_impl_u64( +macro_rules! to_json_impl_u64 { ($($t:ty), +) => ( $(impl ToJson for $t { fn to_json(&self) -> Json { Json::U64(*self as u64) } })+ ) -) +} -to_json_impl_u64!(uint, u8, u16, u32, u64) +to_json_impl_u64! { uint, u8, u16, u32, u64 } impl ToJson for Json { fn to_json(&self) -> Json { self.clone() } @@ -2730,7 +2730,7 @@ mod tests { ); } - macro_rules! check_encoder_for_simple( + macro_rules! check_encoder_for_simple { ($value:expr, $expected:expr) => ({ let s = with_str_writer(|writer| { let mut encoder = Encoder::new(writer); @@ -2744,7 +2744,7 @@ mod tests { }); assert_eq!(s, $expected); }) - ) + } #[test] fn test_write_some() { @@ -2948,7 +2948,7 @@ mod tests { #[test] fn test_decode_tuple() { let t: (uint, uint, uint) = super::decode("[1, 2, 3]").unwrap(); - assert_eq!(t, (1u, 2, 3)) + assert_eq!(t, (1u, 2, 3)); let t: (uint, string::String) = super::decode("[1, \"two\"]").unwrap(); assert_eq!(t, (1u, "two".into_string())); diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 0e0d3b4115b..00c5158309e 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -474,7 +474,9 @@ impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for Option<T> { } } -macro_rules! peel(($name:ident, $($other:ident,)*) => (tuple!($($other,)*))) +macro_rules! peel { + ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* }) +} /// Evaluates to the number of identifiers passed to it, for example: `count_idents!(a, b, c) == 3 macro_rules! count_idents { @@ -482,7 +484,7 @@ macro_rules! count_idents { ($_i:ident $(, $rest:ident)*) => { 1 + count_idents!($($rest),*) } } -macro_rules! tuple ( +macro_rules! tuple { () => (); ( $($name:ident,)+ ) => ( impl<E, D:Decoder<E>,$($name:Decodable<D, E>),*> Decodable<D,E> for ($($name,)*) { @@ -511,9 +513,9 @@ macro_rules! tuple ( }) } } - peel!($($name,)*) + peel! { $($name,)* } ) -) +} tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } |
