mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-27 23:30:34 +08:00
git-ref-format: DoubleEndedIterator for Components
Add DoubleEndedIterator implementations for the two Components iterators. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user