Skip to content

Commit d07aa2e

Browse files
committed
Add Display bound to FromHex error type in serde_util
Ensures hex deserialization errors can be properly formatted and displayed.
1 parent bf30396 commit d07aa2e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/serde_utils.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,16 @@ pub mod hex_bytes {
238238
}
239239

240240
pub fn deserialize<'de, D, B>(d: D) -> Result<B, D::Error>
241-
where D: serde::Deserializer<'de>, B: serde::Deserialize<'de> + FromHex,
241+
where D: serde::Deserializer<'de>,
242+
B: serde::Deserialize<'de> + FromHex,
243+
<B as FromHex>::Err: std::fmt::Display,
242244
{
243245
struct Visitor<B>(::std::marker::PhantomData<B>);
244246

245-
impl<B: FromHex> serde::de::Visitor<'_> for Visitor<B> {
247+
impl<B: FromHex> serde::de::Visitor<'_> for Visitor<B>
248+
where
249+
<B as FromHex>::Err: std::fmt::Display,
250+
{
246251
type Value = B;
247252

248253
fn expecting(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {

0 commit comments

Comments
 (0)