diff --git a/crates/uv-git-types/src/reference.rs b/crates/uv-git-types/src/reference.rs index 247f618ddc93d..ac1bd297c1d55 100644 --- a/crates/uv-git-types/src/reference.rs +++ b/crates/uv-git-types/src/reference.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::fmt::Display; use std::str; @@ -69,13 +70,13 @@ impl GitReference { } /// Converts the [`GitReference`] to a percent-encoded revision string for use in a URL. - pub fn as_url_rev(&self) -> Option { + pub fn as_url_rev(&self) -> Option> { self.as_str().map(Self::encode_rev) } /// Percent-encode a revision string for use in a URL. - pub(crate) fn encode_rev(rev: &str) -> String { - utf8_percent_encode(rev, GIT_REFERENCE_ENCODE_SET).to_string() + pub(crate) fn encode_rev(rev: &str) -> Cow<'_, str> { + utf8_percent_encode(rev, GIT_REFERENCE_ENCODE_SET).into() } /// Returns the kind of this reference.