From d6c7bb29abc0f0050e2efe8de47397eaa4564f6f Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 16 Nov 2022 13:47:22 +0000 Subject: [PATCH] git-ref-format: Component::from_refstr Improve Component::from_refstring by redefining it as Component::from_refstr. This allows the use of `RefStr` or `RefString` instead of just RefString. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- git-ref-format/core/src/name/iter.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-ref-format/core/src/name/iter.rs b/git-ref-format/core/src/name/iter.rs index 948656e..de14c5f 100644 --- a/git-ref-format/core/src/name/iter.rs +++ b/git-ref-format/core/src/name/iter.rs @@ -9,7 +9,7 @@ use std::{ ops::Deref, }; -use super::{RefStr, RefString}; +use super::RefStr; use crate::lit; pub type Iter<'a> = std::str::Split<'a, char>; @@ -52,9 +52,10 @@ pub struct Component<'a>(Cow<'a, RefStr>); impl<'a> Component<'a> { #[inline] - pub fn from_refstring(r: RefString) -> Option { + pub fn from_refstr(r: impl Into>) -> Option { + let r = r.into(); if !r.contains('/') { - Some(Self(Cow::Owned(r))) + Some(Self(r)) } else { None }