From 9d9a31bef3fc888e7a0745e6e685d5f2232aab12 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 22 Jul 2022 01:23:58 +1000 Subject: [PATCH] Optimize `Deserialize` impl for `CrateVersionSource` Use `<&str>::deserialize` instead of `String::deserialize` to avoid intermediate `String`. Signed-off-by: Jiahao XU --- src/metafiles/cvs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/metafiles/cvs.rs b/src/metafiles/cvs.rs index 2b8f2214..d63d35cf 100644 --- a/src/metafiles/cvs.rs +++ b/src/metafiles/cvs.rs @@ -116,6 +116,7 @@ impl<'de> Deserialize<'de> for CrateVersionSource { where D: Deserializer<'de>, { - Self::from_str(&String::deserialize(deserializer)?).map_err(serde::de::Error::custom) + let s = <&str>::deserialize(deserializer)?; + Self::from_str(s).map_err(serde::de::Error::custom) } }