Fix deserialize impl for RelayId.

We need to handle String, not just str, since some deserializers
have to handle escapes and generate new strings.

Found while writing tests; fixes #605.
This commit is contained in:
Nick Mathewson 2022-10-15 10:04:37 -04:00
parent ddc5b63a19
commit ae07909a02
1 changed files with 1 additions and 1 deletions

View File

@ -284,7 +284,7 @@ impl<'de> serde::Deserialize<'de> for RelayId {
// TODO(nickm): maybe allow bytes when dealing with non-human-readable
// formats.
use serde::de::Error as _;
let s = <&str as serde::Deserialize>::deserialize(deserializer)?;
let s = <std::borrow::Cow<'_, str> as serde::Deserialize>::deserialize(deserializer)?;
s.parse()
.map_err(|e: RelayIdError| D::Error::custom(e.to_string()))
}