From b0035528c16defa0914f4c42317269ccac0718a8 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Fri, 5 Jan 2024 14:49:26 +0100 Subject: [PATCH] feat: allow using str in HashMaps with PackageName --- crates/rattler_conda_types/src/package_name.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/rattler_conda_types/src/package_name.rs b/crates/rattler_conda_types/src/package_name.rs index 5367b5ca8..dcf20e392 100644 --- a/crates/rattler_conda_types/src/package_name.rs +++ b/crates/rattler_conda_types/src/package_name.rs @@ -1,6 +1,7 @@ use crate::utils::serde::DeserializeFromStrUnchecked; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_with::{DeserializeAs, DeserializeFromStr}; +use std::borrow::Borrow; use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use std::str::FromStr; @@ -144,6 +145,12 @@ impl<'de> DeserializeAs<'de, PackageName> for DeserializeFromStrUnchecked { } } +impl Borrow for PackageName { + fn borrow(&self) -> &str { + self.as_normalized() + } +} + #[cfg(test)] mod test { use super::*;