diff --git a/CHANGELOG.md b/CHANGELOG.md index eb8f9284e..b670400a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,3 @@ - ## Pending The main features of this release are: @@ -59,6 +58,7 @@ The main features of this release are: - #144 (ark-poly) Add serialization for polynomials and evaluations - #149 (ark-serialize) Add an impl of `CanonicalSerialize/Deserialize` for `String`. - #153 (ark-serialize) Add an impl of `CanonicalSerialize/Deserialize` for `Rc`. +- #158 (ark-serialize) Add an impl of `CanonicalSerialize/Deserialize` for `()`. ### Bug fixes - #36 (ark-ec) In Short-Weierstrass curves, include an infinity bit in `ToConstraintField`. diff --git a/serialize/src/lib.rs b/serialize/src/lib.rs index 50af4f496..4635dd95d 100644 --- a/serialize/src/lib.rs +++ b/serialize/src/lib.rs @@ -352,13 +352,13 @@ pub const fn buffer_byte_size(modulus_bits: usize) -> usize { // Implement Serialization for tuples macro_rules! impl_tuple { - ($( $ty: ident : $no: tt, )+) => { - impl<$($ty, )+> CanonicalSerialize for ($($ty,)+) where - $($ty: CanonicalSerialize,)+ + ($( $ty: ident : $no: tt, )*) => { + impl<$($ty, )*> CanonicalSerialize for ($($ty,)*) where + $($ty: CanonicalSerialize,)* { #[inline] - fn serialize(&self, mut writer: W) -> Result<(), SerializationError> { - $(self.$no.serialize(&mut writer)?;)* + fn serialize(&self, mut _writer: W) -> Result<(), SerializationError> { + $(self.$no.serialize(&mut _writer)?;)* Ok(()) } @@ -370,14 +370,14 @@ macro_rules! impl_tuple { } #[inline] - fn serialize_uncompressed(&self, mut writer: W) -> Result<(), SerializationError> { - $(self.$no.serialize_uncompressed(&mut writer)?;)* + fn serialize_uncompressed(&self, mut _writer: W) -> Result<(), SerializationError> { + $(self.$no.serialize_uncompressed(&mut _writer)?;)* Ok(()) } #[inline] - fn serialize_unchecked(&self, mut writer: W) -> Result<(), SerializationError> { - $(self.$no.serialize_unchecked(&mut writer)?;)* + fn serialize_unchecked(&self, mut _writer: W) -> Result<(), SerializationError> { + $(self.$no.serialize_unchecked(&mut _writer)?;)* Ok(()) } @@ -389,33 +389,34 @@ macro_rules! impl_tuple { } } - impl<$($ty, )+> CanonicalDeserialize for ($($ty,)+) where - $($ty: CanonicalDeserialize,)+ + impl<$($ty, )*> CanonicalDeserialize for ($($ty,)*) where + $($ty: CanonicalDeserialize,)* { #[inline] - fn deserialize(mut reader: R) -> Result { + fn deserialize(mut _reader: R) -> Result { Ok(($( - $ty::deserialize(&mut reader)?, - )+)) + $ty::deserialize(&mut _reader)?, + )*)) } #[inline] - fn deserialize_uncompressed(mut reader: R) -> Result { + fn deserialize_uncompressed(mut _reader: R) -> Result { Ok(($( - $ty::deserialize_uncompressed(&mut reader)?, - )+)) + $ty::deserialize_uncompressed(&mut _reader)?, + )*)) } #[inline] - fn deserialize_unchecked(mut reader: R) -> Result { + fn deserialize_unchecked(mut _reader: R) -> Result { Ok(($( - $ty::deserialize_unchecked(&mut reader)?, - )+)) + $ty::deserialize_unchecked(&mut _reader)?, + )*)) } } } } +impl_tuple!(); impl_tuple!(A:0, B:1,); impl_tuple!(A:0, B:1, C:2,); impl_tuple!(A:0, B:1, C:2, D:3,); @@ -967,6 +968,8 @@ mod test { #[test] fn test_tuple() { + test_serialize(()); + test_serialize((123u64, Dummy)); test_serialize((123u64, 234u32, Dummy)); }