From 53565a816c16c6836182b87eb5cc22aa156e769f Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 15 Feb 2023 09:33:44 -0800 Subject: [PATCH] revset: rename 'repo lifetime to the more accurate 'index --- lib/src/revset.rs | 232 +++++++++++++++---------------- lib/src/revset_graph_iterator.rs | 34 ++--- 2 files changed, 133 insertions(+), 133 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 1961f3d43..1218ca58d 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -536,11 +536,11 @@ impl RevsetExpression { Rc::new(RevsetExpression::Difference(self.clone(), other.clone())) } - pub fn evaluate<'repo>( + pub fn evaluate<'index>( &self, - repo: &'repo dyn Repo, + repo: &'index dyn Repo, workspace_ctx: Option<&RevsetWorkspaceContext>, - ) -> Result + 'repo>, RevsetError> { + ) -> Result + 'index>, RevsetError> { evaluate_expression(repo, self, workspace_ctx) } } @@ -1521,9 +1521,9 @@ pub fn optimize(expression: Rc) -> Rc { fold_difference(&expression).unwrap_or(expression) } -pub trait Revset<'repo>: ToPredicateFn<'repo> { +pub trait Revset<'index>: ToPredicateFn<'index> { // All revsets currently iterate in order of descending index position - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo>; + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index>; fn is_empty(&self) -> bool { self.iter().next().is_none() @@ -1531,53 +1531,53 @@ pub trait Revset<'repo>: ToPredicateFn<'repo> { } // This trait is implementation detail, which can be hidden in private module. -pub trait ToPredicateFn<'repo> { +pub trait ToPredicateFn<'index> { /// Creates function that tests if the given entry is included in the set. /// /// The predicate function is evaluated in order of `RevsetIterator`. - fn to_predicate_fn(&self) -> Box) -> bool + '_>; + fn to_predicate_fn(&self) -> Box) -> bool + '_>; } -impl<'repo, T> ToPredicateFn<'repo> for Box +impl<'index, T> ToPredicateFn<'index> for Box where - T: ToPredicateFn<'repo> + ?Sized, + T: ToPredicateFn<'index> + ?Sized, { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { - >::to_predicate_fn(self) + fn to_predicate_fn(&self) -> Box) -> bool + '_> { + >::to_predicate_fn(self) } } -pub struct RevsetIterator<'revset, 'repo: 'revset> { - inner: Box> + 'revset>, +pub struct RevsetIterator<'revset, 'index: 'revset> { + inner: Box> + 'revset>, } -impl<'revset, 'repo> RevsetIterator<'revset, 'repo> { - fn new(inner: Box> + 'revset>) -> Self { +impl<'revset, 'index> RevsetIterator<'revset, 'index> { + fn new(inner: Box> + 'revset>) -> Self { Self { inner } } - pub fn commit_ids(self) -> RevsetCommitIdIterator<'revset, 'repo> { + pub fn commit_ids(self) -> RevsetCommitIdIterator<'revset, 'index> { RevsetCommitIdIterator(self.inner) } - pub fn commits(self, store: &Arc) -> RevsetCommitIterator<'revset, 'repo> { + pub fn commits(self, store: &Arc) -> RevsetCommitIterator<'revset, 'index> { RevsetCommitIterator { iter: self.inner, store: store.clone(), } } - pub fn reversed(self) -> ReverseRevsetIterator<'repo> { + pub fn reversed(self) -> ReverseRevsetIterator<'index> { ReverseRevsetIterator { entries: self.into_iter().collect_vec(), } } - pub fn graph(self) -> RevsetGraphIterator<'revset, 'repo> { + pub fn graph(self) -> RevsetGraphIterator<'revset, 'index> { RevsetGraphIterator::new(self) } - fn into_predicate_fn(self) -> Box) -> bool + 'revset> { + fn into_predicate_fn(self) -> Box) -> bool + 'revset> { let mut iter = self.fuse().peekable(); Box::new(move |entry| { while iter.next_if(|e| e.position() > entry.position()).is_some() { @@ -1588,16 +1588,16 @@ impl<'revset, 'repo> RevsetIterator<'revset, 'repo> { } } -impl<'repo> Iterator for RevsetIterator<'_, 'repo> { - type Item = IndexEntry<'repo>; +impl<'index> Iterator for RevsetIterator<'_, 'index> { + type Item = IndexEntry<'index>; fn next(&mut self) -> Option { self.inner.next() } } -pub struct RevsetCommitIdIterator<'revset, 'repo: 'revset>( - Box> + 'revset>, +pub struct RevsetCommitIdIterator<'revset, 'index: 'revset>( + Box> + 'revset>, ); impl Iterator for RevsetCommitIdIterator<'_, '_> { @@ -1608,9 +1608,9 @@ impl Iterator for RevsetCommitIdIterator<'_, '_> { } } -pub struct RevsetCommitIterator<'revset, 'repo: 'revset> { +pub struct RevsetCommitIterator<'revset, 'index: 'revset> { store: Arc, - iter: Box> + 'revset>, + iter: Box> + 'revset>, } impl Iterator for RevsetCommitIterator<'_, '_> { @@ -1623,20 +1623,20 @@ impl Iterator for RevsetCommitIterator<'_, '_> { } } -pub struct ReverseRevsetIterator<'repo> { - entries: Vec>, +pub struct ReverseRevsetIterator<'index> { + entries: Vec>, } -impl<'repo> Iterator for ReverseRevsetIterator<'repo> { - type Item = IndexEntry<'repo>; +impl<'index> Iterator for ReverseRevsetIterator<'index> { + type Item = IndexEntry<'index>; fn next(&mut self) -> Option { self.entries.pop() } } -struct EagerRevset<'repo> { - index_entries: Vec>, +struct EagerRevset<'index> { + index_entries: Vec>, } impl EagerRevset<'static> { @@ -1647,54 +1647,54 @@ impl EagerRevset<'static> { } } -impl<'repo> Revset<'repo> for EagerRevset<'repo> { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { +impl<'index> Revset<'index> for EagerRevset<'index> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { RevsetIterator::new(Box::new(self.index_entries.iter().cloned())) } } -impl<'repo> ToPredicateFn<'repo> for EagerRevset<'repo> { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { +impl<'index> ToPredicateFn<'index> for EagerRevset<'index> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { self.iter().into_predicate_fn() } } -struct RevWalkRevset<'repo, T> +struct RevWalkRevset<'index, T> where - // RevWalkRevset<'repo> appears to be needed to assert 'repo outlives 'a + // RevWalkRevset<'index> appears to be needed to assert 'index outlives 'a // in to_predicate_fn<'a>(&'a self) -> Box. - T: Iterator>, + T: Iterator>, { walk: T, } -impl<'repo, T> Revset<'repo> for RevWalkRevset<'repo, T> +impl<'index, T> Revset<'index> for RevWalkRevset<'index, T> where - T: Iterator> + Clone, + T: Iterator> + Clone, { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { RevsetIterator::new(Box::new(self.walk.clone())) } } -impl<'repo, T> ToPredicateFn<'repo> for RevWalkRevset<'repo, T> +impl<'index, T> ToPredicateFn<'index> for RevWalkRevset<'index, T> where - T: Iterator> + Clone, + T: Iterator> + Clone, { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { self.iter().into_predicate_fn() } } -struct ChildrenRevset<'revset, 'repo: 'revset> { +struct ChildrenRevset<'revset, 'index: 'revset> { // The revisions we want to find children for - root_set: Box + 'revset>, + root_set: Box + 'revset>, // Consider only candidates from this set - candidate_set: Box + 'revset>, + candidate_set: Box + 'revset>, } -impl<'repo> Revset<'repo> for ChildrenRevset<'_, 'repo> { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { +impl<'index> Revset<'index> for ChildrenRevset<'_, 'index> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { let roots: HashSet<_> = self .root_set .iter() @@ -1712,33 +1712,33 @@ impl<'repo> Revset<'repo> for ChildrenRevset<'_, 'repo> { } } -impl<'repo> ToPredicateFn<'repo> for ChildrenRevset<'_, 'repo> { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { +impl<'index> ToPredicateFn<'index> for ChildrenRevset<'_, 'index> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { // TODO: can be optimized if candidate_set contains all heads self.iter().into_predicate_fn() } } -struct FilterRevset<'revset, 'repo: 'revset, P> { - candidates: Box + 'revset>, +struct FilterRevset<'revset, 'index: 'revset, P> { + candidates: Box + 'revset>, predicate: P, } -impl<'repo, P> Revset<'repo> for FilterRevset<'_, 'repo, P> +impl<'index, P> Revset<'index> for FilterRevset<'_, 'index, P> where - P: ToPredicateFn<'repo>, + P: ToPredicateFn<'index>, { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { let p = self.predicate.to_predicate_fn(); RevsetIterator::new(Box::new(self.candidates.iter().filter(p))) } } -impl<'repo, P> ToPredicateFn<'repo> for FilterRevset<'_, 'repo, P> +impl<'index, P> ToPredicateFn<'index> for FilterRevset<'_, 'index, P> where - P: ToPredicateFn<'repo>, + P: ToPredicateFn<'index>, { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { // TODO: optimize 'p1' out if candidates = All let mut p1 = self.candidates.to_predicate_fn(); let mut p2 = self.predicate.to_predicate_fn(); @@ -1746,13 +1746,13 @@ where } } -struct UnionRevset<'revset, 'repo: 'revset> { - set1: Box + 'revset>, - set2: Box + 'revset>, +struct UnionRevset<'revset, 'index: 'revset> { + set1: Box + 'revset>, + set2: Box + 'revset>, } -impl<'repo> Revset<'repo> for UnionRevset<'_, 'repo> { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { +impl<'index> Revset<'index> for UnionRevset<'_, 'index> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { RevsetIterator::new(Box::new(UnionRevsetIterator { iter1: self.set1.iter().peekable(), iter2: self.set2.iter().peekable(), @@ -1760,21 +1760,21 @@ impl<'repo> Revset<'repo> for UnionRevset<'_, 'repo> { } } -impl<'repo> ToPredicateFn<'repo> for UnionRevset<'_, 'repo> { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { +impl<'index> ToPredicateFn<'index> for UnionRevset<'_, 'index> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { let mut p1 = self.set1.to_predicate_fn(); let mut p2 = self.set2.to_predicate_fn(); Box::new(move |entry| p1(entry) || p2(entry)) } } -struct UnionRevsetIterator<'revset, 'repo> { - iter1: Peekable>, - iter2: Peekable>, +struct UnionRevsetIterator<'revset, 'index> { + iter1: Peekable>, + iter2: Peekable>, } -impl<'revset, 'repo> Iterator for UnionRevsetIterator<'revset, 'repo> { - type Item = IndexEntry<'repo>; +impl<'revset, 'index> Iterator for UnionRevsetIterator<'revset, 'index> { + type Item = IndexEntry<'index>; fn next(&mut self) -> Option { match (self.iter1.peek(), self.iter2.peek()) { @@ -1792,13 +1792,13 @@ impl<'revset, 'repo> Iterator for UnionRevsetIterator<'revset, 'repo> { } } -struct IntersectionRevset<'revset, 'repo: 'revset> { - set1: Box + 'revset>, - set2: Box + 'revset>, +struct IntersectionRevset<'revset, 'index: 'revset> { + set1: Box + 'revset>, + set2: Box + 'revset>, } -impl<'repo> Revset<'repo> for IntersectionRevset<'_, 'repo> { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { +impl<'index> Revset<'index> for IntersectionRevset<'_, 'index> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { RevsetIterator::new(Box::new(IntersectionRevsetIterator { iter1: self.set1.iter().peekable(), iter2: self.set2.iter().peekable(), @@ -1806,21 +1806,21 @@ impl<'repo> Revset<'repo> for IntersectionRevset<'_, 'repo> { } } -impl<'repo> ToPredicateFn<'repo> for IntersectionRevset<'_, 'repo> { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { +impl<'index> ToPredicateFn<'index> for IntersectionRevset<'_, 'index> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { let mut p1 = self.set1.to_predicate_fn(); let mut p2 = self.set2.to_predicate_fn(); Box::new(move |entry| p1(entry) && p2(entry)) } } -struct IntersectionRevsetIterator<'revset, 'repo> { - iter1: Peekable>, - iter2: Peekable>, +struct IntersectionRevsetIterator<'revset, 'index> { + iter1: Peekable>, + iter2: Peekable>, } -impl<'revset, 'repo> Iterator for IntersectionRevsetIterator<'revset, 'repo> { - type Item = IndexEntry<'repo>; +impl<'revset, 'index> Iterator for IntersectionRevsetIterator<'revset, 'index> { + type Item = IndexEntry<'index>; fn next(&mut self) -> Option { loop { @@ -1848,15 +1848,15 @@ impl<'revset, 'repo> Iterator for IntersectionRevsetIterator<'revset, 'repo> { } } -struct DifferenceRevset<'revset, 'repo: 'revset> { +struct DifferenceRevset<'revset, 'index: 'revset> { // The minuend (what to subtract from) - set1: Box + 'revset>, + set1: Box + 'revset>, // The subtrahend (what to subtract) - set2: Box + 'revset>, + set2: Box + 'revset>, } -impl<'repo> Revset<'repo> for DifferenceRevset<'_, 'repo> { - fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'repo> { +impl<'index> Revset<'index> for DifferenceRevset<'_, 'index> { + fn iter<'revset>(&'revset self) -> RevsetIterator<'revset, 'index> { RevsetIterator::new(Box::new(DifferenceRevsetIterator { iter1: self.set1.iter().peekable(), iter2: self.set2.iter().peekable(), @@ -1864,8 +1864,8 @@ impl<'repo> Revset<'repo> for DifferenceRevset<'_, 'repo> { } } -impl<'repo> ToPredicateFn<'repo> for DifferenceRevset<'_, 'repo> { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { +impl<'index> ToPredicateFn<'index> for DifferenceRevset<'_, 'index> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { // TODO: optimize 'p1' out for unary negate? let mut p1 = self.set1.to_predicate_fn(); let mut p2 = self.set2.to_predicate_fn(); @@ -1873,13 +1873,13 @@ impl<'repo> ToPredicateFn<'repo> for DifferenceRevset<'_, 'repo> { } } -struct DifferenceRevsetIterator<'revset, 'repo> { - iter1: Peekable>, - iter2: Peekable>, +struct DifferenceRevsetIterator<'revset, 'index> { + iter1: Peekable>, + iter2: Peekable>, } -impl<'revset, 'repo> Iterator for DifferenceRevsetIterator<'revset, 'repo> { - type Item = IndexEntry<'repo>; +impl<'revset, 'index> Iterator for DifferenceRevsetIterator<'revset, 'index> { + type Item = IndexEntry<'index>; fn next(&mut self) -> Option { loop { @@ -1915,11 +1915,11 @@ pub struct RevsetWorkspaceContext<'a> { pub workspace_root: &'a Path, } -pub fn evaluate_expression<'repo>( - repo: &'repo dyn Repo, +pub fn evaluate_expression<'index>( + repo: &'index dyn Repo, expression: &RevsetExpression, workspace_ctx: Option<&RevsetWorkspaceContext>, -) -> Result + 'repo>, RevsetError> { +) -> Result + 'index>, RevsetError> { match expression { RevsetExpression::None => Ok(Box::new(EagerRevset::empty())), RevsetExpression::All => { @@ -2126,10 +2126,10 @@ pub fn evaluate_expression<'repo>( } } -fn revset_for_commit_ids<'revset, 'repo: 'revset>( - repo: &'repo dyn Repo, +fn revset_for_commit_ids<'revset, 'index: 'revset>( + repo: &'index dyn Repo, commit_ids: &[CommitId], -) -> Box + 'revset> { +) -> Box + 'revset> { let index = repo.index(); let mut index_entries = vec![]; for id in commit_ids { @@ -2140,10 +2140,10 @@ fn revset_for_commit_ids<'revset, 'repo: 'revset>( Box::new(EagerRevset { index_entries }) } -pub fn revset_for_commits<'revset, 'repo: 'revset>( - repo: &'repo dyn Repo, +pub fn revset_for_commits<'revset, 'index: 'revset>( + repo: &'index dyn Repo, commits: &[&Commit], -) -> Box + 'revset> { +) -> Box + 'revset> { let index = repo.index(); let mut index_entries = commits .iter() @@ -2153,18 +2153,18 @@ pub fn revset_for_commits<'revset, 'repo: 'revset>( Box::new(EagerRevset { index_entries }) } -type PurePredicateFn<'repo> = Box) -> bool + 'repo>; +type PurePredicateFn<'index> = Box) -> bool + 'index>; -impl<'repo> ToPredicateFn<'repo> for PurePredicateFn<'repo> { - fn to_predicate_fn(&self) -> Box) -> bool + '_> { +impl<'index> ToPredicateFn<'index> for PurePredicateFn<'index> { + fn to_predicate_fn(&self) -> Box) -> bool + '_> { Box::new(self) } } -fn build_predicate_fn<'repo>( - repo: &'repo dyn Repo, +fn build_predicate_fn<'index>( + repo: &'index dyn Repo, predicate: &RevsetFilterPredicate, -) -> PurePredicateFn<'repo> { +) -> PurePredicateFn<'index> { match predicate { RevsetFilterPredicate::ParentCount(parent_count_range) => { let parent_count_range = parent_count_range.clone(); @@ -2211,11 +2211,11 @@ fn build_predicate_fn<'repo>( } } -pub fn filter_by_diff<'revset, 'repo: 'revset>( - repo: &'repo dyn Repo, - matcher: impl Borrow + 'repo, - candidates: Box + 'revset>, -) -> Box + 'revset> { +pub fn filter_by_diff<'revset, 'index: 'revset>( + repo: &'index dyn Repo, + matcher: impl Borrow + 'index, + candidates: Box + 'revset>, +) -> Box + 'revset> { Box::new(FilterRevset:: { candidates, predicate: Box::new(move |entry| has_diff_from_parent(repo, entry, matcher.borrow())), diff --git a/lib/src/revset_graph_iterator.rs b/lib/src/revset_graph_iterator.rs index 94bdbbd6c..8f94d6278 100644 --- a/lib/src/revset_graph_iterator.rs +++ b/lib/src/revset_graph_iterator.rs @@ -119,11 +119,11 @@ pub enum RevsetGraphEdgeType { // by stopping at "c" since we're only interested in edges that could lead to // "D", but that would require extra book-keeping to remember for later that the // edges from "f" and "H" are only partially computed. -pub struct RevsetGraphIterator<'revset, 'repo> { - input_set_iter: RevsetIterator<'revset, 'repo>, +pub struct RevsetGraphIterator<'revset, 'index> { + input_set_iter: RevsetIterator<'revset, 'index>, // Commits in the input set we had to take out of the iterator while walking external // edges. Does not necessarily include the commit we're currently about to emit. - look_ahead: BTreeMap>, + look_ahead: BTreeMap>, // The last consumed position. This is always the smallest key in the look_ahead map, but it's // faster to keep a separate field for it. min_position: IndexPosition, @@ -133,8 +133,8 @@ pub struct RevsetGraphIterator<'revset, 'repo> { skip_transitive_edges: bool, } -impl<'revset, 'repo> RevsetGraphIterator<'revset, 'repo> { - pub fn new(iter: RevsetIterator<'revset, 'repo>) -> RevsetGraphIterator<'revset, 'repo> { +impl<'revset, 'index> RevsetGraphIterator<'revset, 'index> { + pub fn new(iter: RevsetIterator<'revset, 'index>) -> RevsetGraphIterator<'revset, 'index> { RevsetGraphIterator { input_set_iter: iter, look_ahead: Default::default(), @@ -149,11 +149,11 @@ impl<'revset, 'repo> RevsetGraphIterator<'revset, 'repo> { self } - pub fn reversed(self) -> ReverseRevsetGraphIterator<'repo> { + pub fn reversed(self) -> ReverseRevsetGraphIterator<'index> { ReverseRevsetGraphIterator::new(self) } - fn next_index_entry(&mut self) -> Option> { + fn next_index_entry(&mut self) -> Option> { if let Some(index_entry) = self.look_ahead.pop_last_value() { return Some(index_entry); } @@ -162,7 +162,7 @@ impl<'revset, 'repo> RevsetGraphIterator<'revset, 'repo> { fn edges_from_internal_commit( &mut self, - index_entry: &IndexEntry<'repo>, + index_entry: &IndexEntry<'index>, ) -> HashSet { if let Some(edges) = self.edges.get(&index_entry.position()) { return edges.clone(); @@ -191,7 +191,7 @@ impl<'revset, 'repo> RevsetGraphIterator<'revset, 'repo> { fn edges_from_external_commit( &mut self, - index_entry: IndexEntry<'repo>, + index_entry: IndexEntry<'index>, ) -> HashSet { let position = index_entry.position(); let mut stack = vec![index_entry]; @@ -294,8 +294,8 @@ impl<'revset, 'repo> RevsetGraphIterator<'revset, 'repo> { } } -impl<'revset, 'repo> Iterator for RevsetGraphIterator<'revset, 'repo> { - type Item = (IndexEntry<'repo>, Vec); +impl<'revset, 'index> Iterator for RevsetGraphIterator<'revset, 'index> { + type Item = (IndexEntry<'index>, Vec); fn next(&mut self) -> Option { let index_entry = self.next_index_entry()?; @@ -309,12 +309,12 @@ impl<'revset, 'repo> Iterator for RevsetGraphIterator<'revset, 'repo> { } } -pub struct ReverseRevsetGraphIterator<'repo> { - items: Vec<(IndexEntry<'repo>, Vec)>, +pub struct ReverseRevsetGraphIterator<'index> { + items: Vec<(IndexEntry<'index>, Vec)>, } -impl<'repo> ReverseRevsetGraphIterator<'repo> { - fn new<'revset>(input: RevsetGraphIterator<'revset, 'repo>) -> Self { +impl<'index> ReverseRevsetGraphIterator<'index> { + fn new<'revset>(input: RevsetGraphIterator<'revset, 'index>) -> Self { let mut entries = vec![]; let mut reverse_edges: HashMap> = HashMap::new(); for (entry, edges) in input { @@ -342,8 +342,8 @@ impl<'repo> ReverseRevsetGraphIterator<'repo> { } } -impl<'repo> Iterator for ReverseRevsetGraphIterator<'repo> { - type Item = (IndexEntry<'repo>, Vec); +impl<'index> Iterator for ReverseRevsetGraphIterator<'index> { + type Item = (IndexEntry<'index>, Vec); fn next(&mut self) -> Option { self.items.pop()