Radish alpha
r
Git libraries for Radicle
Radicle
Git (anonymous pull)
Log in to clone via SSH
git-ref-format: DoubleEndedIterator for Components
Fintan Halpenny committed 3 years ago
commit cf1594cf43e23c9fc8f74cf69e22f81227e82f2b
parent 6479ba091fa3ee3b16fba61138cfd8c6ec6d985d
2 files changed +22 -0
modified git-ref-format/core/src/name/iter.rs
@@ -34,6 +34,17 @@ impl<'a> Iterator for Components<'a> {
    }
}

+
impl<'a> DoubleEndedIterator for Components<'a> {
+
    #[inline]
+
    fn next_back(&mut self) -> Option<Self::Item> {
+
        self.inner
+
            .next_back()
+
            .map(RefStr::from_str)
+
            .map(Cow::from)
+
            .map(Component)
+
    }
+
}
+

impl<'a> From<&'a RefStr> for Components<'a> {
    #[inline]
    fn from(rs: &'a RefStr) -> Self {
modified git-ref-format/core/src/refspec/iter.rs
@@ -66,6 +66,17 @@ impl<'a> Iterator for Components<'a> {
    }
}

+
impl<'a> DoubleEndedIterator for Components<'a> {
+
    #[inline]
+
    fn next_back(&mut self) -> Option<Self::Item> {
+
        self.inner.next_back().map(|next| match next {
+
            "*" => Component::Glob(None),
+
            x if x.contains('*') => Component::Glob(Some(PatternStr::from_str(x))),
+
            x => Component::Normal(RefStr::from_str(x)),
+
        })
+
    }
+
}
+

impl<'a> From<&'a PatternStr> for Components<'a> {
    #[inline]
    fn from(p: &'a PatternStr) -> Self {