From f018c0c62fcbaf66945ab44868ecbf41d2f342f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Sat, 2 Sep 2023 17:08:11 -0400 Subject: [PATCH] fixup! fix: Improve serialization for prime fields --- src/derive/field.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/derive/field.rs b/src/derive/field.rs index f1c765fb..da962457 100644 --- a/src/derive/field.rs +++ b/src/derive/field.rs @@ -714,12 +714,9 @@ macro_rules! serialize_deserialize_32_byte_primefield { } else { <[u8; 32]>::deserialize(deserializer)? }; - match Self::from_repr(bytes).into() { - Some(fq) => Ok(fq), - None => Err(D::Error::custom( - "deserialized bytes don't encode a valid field element", - )), - } + Option::from(Self::from_repr(bytes)).ok_or_else(|| { + D::Error::custom("deserialized bytes don't encode a valid field element") + }) } } };