Skip to content

Commit

Permalink
revset: detach index from InternalRevset::positions()
Browse files Browse the repository at this point in the history
Perhaps, union/intersection/difference combinators can be moved to the
rev_walk module, but let's think about that later.
  • Loading branch information
yuja committed Mar 12, 2024
1 parent 78dbaba commit 2839074
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 151 deletions.
9 changes: 8 additions & 1 deletion lib/src/default_index/rev_walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ pub(super) trait RevWalk<I: ?Sized> {
}
}

impl<I: ?Sized, W: RevWalk<I> + ?Sized> RevWalk<I> for Box<W> {
type Item = W::Item;

fn next(&mut self, index: &I) -> Option<Self::Item> {
<W as RevWalk<I>>::next(self, index)
}
}

/// Adapter that turns `Iterator` into `RevWalk` by dropping index argument.
///
/// As the name suggests, the source object is usually a slice or `Vec`.
Expand Down Expand Up @@ -127,7 +135,6 @@ pub(super) struct PeekableRevWalk<I: ?Sized, W: RevWalk<I>> {
}

impl<I: ?Sized, W: RevWalk<I>> PeekableRevWalk<I, W> {
#[cfg(test)] // TODO
pub fn peek(&mut self, index: &I) -> Option<&W::Item> {
if self.peeked.is_none() {
self.peeked = self.walk.next(index);
Expand Down
Loading

0 comments on commit 2839074

Please sign in to comment.