mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Fix Deserialize
for CrateVersionSource
Use `Cow::<'_, str>::deserialize` to ensure that it would still work even if it contains escaped characters. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
a3fcc298ab
commit
32b98f0c5a
1 changed files with 3 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt, str::FromStr};
|
||||
use std::{borrow::Cow, fmt, str::FromStr};
|
||||
|
||||
use miette::Diagnostic;
|
||||
use once_cell::sync::Lazy;
|
||||
|
@ -116,7 +116,7 @@ impl<'de> Deserialize<'de> for CrateVersionSource {
|
|||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let s = <&str>::deserialize(deserializer)?;
|
||||
Self::from_str(s).map_err(serde::de::Error::custom)
|
||||
let s = Cow::<'_, str>::deserialize(deserializer)?;
|
||||
Self::from_str(&s).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue