Improve ergonomics for qualifier keys #21
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
I was writing some code to remove qualifiers from PURLs and found that you can't do
purl.into_builder()
and then remove all the qualifiers through builder methods without cloning thePurl
or its qualifiers and then removing them one at a time, and even then the generics and type conversions forQualifierKey
would get in the way of calling.without_qualifier
or.with_qualifier
using the keys of an existingPurl
.This PR
AsRef<str>
, even one that isn'tInto<SmallString>
, because removing a qualifier never creates a string.QualifierKey
so that it theQualifierKey
or&QualifierKey
of an existingPurl
can be used as a parameter towith_qualifier
andwithout_qualifier
.without_qualifiers
that removes all qualifiers.It might be nice in some cases to expose
Qualifiers::retain
somehow viaPurlBuilder
but I haven't done it in this PR. It is already possible to do that (and everything else added in this PR) by accessing the qualifiers directly:Checklist
Issue
What issue(s) does this PR close. Use the
closes #<issueNum>
here.