Merge remote-tracking branch 'origin/qualified-ref-import'

* origin/qualified-ref-import:
  git-ref-format: Component::from_refstr
  git-ref-format: import Qualified within macro

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
This commit is contained in:
Fintan Halpenny
2022-11-16 17:58:07 +00:00
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -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<Self> {
pub fn from_refstr(r: impl Into<Cow<'a, RefStr>>) -> Option<Self> {
let r = r.into();
if !r.contains('/') {
Some(Self(Cow::Owned(r)))
Some(Self(r))
} else {
None
}
+1 -1
View File
@@ -66,7 +66,7 @@ pub fn qualified(input: TokenStream) -> TokenStream {
let expand = quote! {
unsafe {
use ::std::{borrow::Cow, mem::transmute};
use ::git_ref_format::{Component, RefStr, RefString};
use ::git_ref_format::{Component, RefStr, RefString, Qualified};
let inner: RefString = transmute(#safe.to_owned());
let cow: Cow<'static, RefStr> = Cow::Owned(inner);