Просмотр исходного кода

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>
Alejandro Martinez Ruiz 5 лет назад
Родитель
Сommit
5910144a36
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      url/src/lib.rs

+ 4 - 2
url/src/lib.rs

@@ -2471,8 +2471,10 @@ impl<'de> serde::Deserialize<'de> for Url {
             where
             where
                 E: Error,
                 E: Error,
             {
             {
-                Url::parse(s)
-                    .map_err(|err| Error::invalid_value(Unexpected::Str(s), &err.description()))
+                Url::parse(s).map_err(|err| {
+                    let err_s = format!("{}", err);
+                    Error::invalid_value(Unexpected::Str(s), &err_s.as_str())
+                })
             }
             }
         }
         }