From 70191dd65ff0a4a16f0ff883c6b5bc5398153856 Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Mon, 25 Nov 2024 08:39:36 -0500 Subject: [PATCH 1/3] remove unnecessary constraint --- purl/src/builder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/purl/src/builder.rs b/purl/src/builder.rs index ff24166..504f971 100644 --- a/purl/src/builder.rs +++ b/purl/src/builder.rs @@ -153,7 +153,6 @@ impl GenericPurlBuilder { pub fn without_qualifier(mut self, k: S) -> Self where S: AsRef, - SmallString: From, { self.parts.qualifiers.remove(k); self From d8282f4868eda91f365eba03b5b83dc1f992e503 Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Mon, 25 Nov 2024 08:54:54 -0500 Subject: [PATCH 2/3] add impls for using QualifierKey as a string --- purl/src/qualifiers.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/purl/src/qualifiers.rs b/purl/src/qualifiers.rs index 6ab8fc4..69e97bb 100644 --- a/purl/src/qualifiers.rs +++ b/purl/src/qualifiers.rs @@ -315,7 +315,7 @@ impl<'a> IntoIterator for &'a mut Qualifiers { /// A case-insensitive qualifier name. /// /// Comparisons between this type and other types are case insensitive. -#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Debug, Default, Eq, Hash, Ord)] pub struct QualifierKey(SmallString); impl PartialEq for QualifierKey @@ -345,6 +345,24 @@ impl Deref for QualifierKey { } } +impl AsRef for QualifierKey { + fn as_ref(&self) -> &str { + self.as_str() + } +} + +impl From for SmallString { + fn from(value: QualifierKey) -> Self { + SmallString::from(value.0) + } +} + +impl From<&QualifierKey> for SmallString { + fn from(value: &QualifierKey) -> Self { + SmallString::from(value.as_str()) + } +} + impl QualifierKey { /// Get a reference to the lower case string. pub fn as_str(&self) -> &str { From 1b09357e2dc85c27b389dedf7c8e4d63509447cc Mon Sep 17 00:00:00 2001 From: Matthew Donoughe Date: Mon, 25 Nov 2024 09:00:48 -0500 Subject: [PATCH 3/3] add without_qualifiers --- purl/src/builder.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/purl/src/builder.rs b/purl/src/builder.rs index 504f971..3e7c2ac 100644 --- a/purl/src/builder.rs +++ b/purl/src/builder.rs @@ -158,6 +158,12 @@ impl GenericPurlBuilder { self } + /// Unset all qualifiers. + pub fn without_qualifiers(mut self) -> Self { + self.parts.qualifiers.clear(); + self + } + /// Set the subpath. /// /// Passing `""` will unset the subpath.