mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-13 11:14:25 +00:00
revset: inline FilterRevsetIterator by using .filter()
This commit is contained in:
parent
5b13c0b38f
commit
fae3822422
@ -1433,23 +1433,7 @@ struct FilterRevset<'revset, 'repo: 'revset> {
|
|||||||
|
|
||||||
impl<'repo> Revset<'repo> for FilterRevset<'_, 'repo> {
|
impl<'repo> Revset<'repo> for FilterRevset<'_, 'repo> {
|
||||||
fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> {
|
fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> {
|
||||||
RevsetIterator::new(Box::new(FilterRevsetIterator {
|
RevsetIterator::new(Box::new(self.candidates.iter().filter(&self.predicate)))
|
||||||
iter: self.candidates.iter(),
|
|
||||||
predicate: self.predicate.as_ref(),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FilterRevsetIterator<'revset, 'repo> {
|
|
||||||
iter: RevsetIterator<'revset, 'repo>,
|
|
||||||
predicate: &'revset dyn Fn(&IndexEntry<'repo>) -> bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'revset, 'repo> Iterator for FilterRevsetIterator<'revset, 'repo> {
|
|
||||||
type Item = IndexEntry<'repo>;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
self.iter.find(self.predicate)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user