Skip to content

Commit 5910144

Browse files
committed
url: use Display rather than Error's description in deserialize
Error's description method has been deprecated since 1.42.0. When deserializing URLs, errors show a Rust-specific programming error message rather than information about what failed, ie: "invalid value: string "a string", expected description() is deprecated; use Display" This patch uses Display on the returned error. Signed-off-by: Alejandro Martinez Ruiz <amr@redhat.com>
1 parent 494b2fc commit 5910144

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

url/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,8 +2471,10 @@ impl<'de> serde::Deserialize<'de> for Url {
24712471
where
24722472
E: Error,
24732473
{
2474-
Url::parse(s)
2475-
.map_err(|err| Error::invalid_value(Unexpected::Str(s), &err.description()))
2474+
Url::parse(s).map_err(|err| {
2475+
let err_s = format!("{}", err);
2476+
Error::invalid_value(Unexpected::Str(s), &err_s.as_str())
2477+
})
24762478
}
24772479
}
24782480

0 commit comments

Comments
 (0)