From 7cf94a2362daf2f0896f8b0a2f0466849903548a Mon Sep 17 00:00:00 2001 From: Stefan Filip Date: Fri, 6 Dec 2019 14:23:01 -0800 Subject: [PATCH] manifest: rename Cursor to DfsCursor Summary: Signal more clearly that the iteration in the cursor is depth first. Reviewed By: quark-zju Differential Revision: D18843135 fbshipit-source-id: 8ee2c612963eaf6fec3ae48f75ebf16bd177fed4 --- eden/scm/lib/manifest/src/tree/iter.rs | 8 ++++---- eden/scm/lib/manifest/src/tree/mod.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eden/scm/lib/manifest/src/tree/iter.rs b/eden/scm/lib/manifest/src/tree/iter.rs index 476b49fa62..c1583b4606 100644 --- a/eden/scm/lib/manifest/src/tree/iter.rs +++ b/eden/scm/lib/manifest/src/tree/iter.rs @@ -93,7 +93,7 @@ impl<'a> Iterator for BfsIter<'a> { /// Because this structure intends to back iterators, it is designed so that `step()` is called on /// every invocation of `next()`. This should simplify iterator implementations what may want to /// return the root of the subtree that is being iterated. -pub struct Cursor<'a> { +pub struct DfsCursor<'a> { state: State, store: &'a InnerStore, path: RepoPathBuf, @@ -121,10 +121,10 @@ enum State { Done, } -impl<'a> Cursor<'a> { +impl<'a> DfsCursor<'a> { /// Default constructor for Cursor. pub fn new(store: &'a InnerStore, path: RepoPathBuf, link: &'a Link) -> Self { - Cursor { + DfsCursor { state: State::Init, store, path, @@ -172,7 +172,7 @@ impl<'a> Cursor<'a> { } } -impl<'a> Cursor<'a> { +impl<'a> DfsCursor<'a> { /// Advances the cursor towards a new [`Link`]. Visiting is done in pre-order. /// Errors are an interesting topic. At the time of this writing errors only appear when /// computing [`DurableEntry`] (which cache their failures). To protect against potential diff --git a/eden/scm/lib/manifest/src/tree/mod.rs b/eden/scm/lib/manifest/src/tree/mod.rs index 68ebbed297..8992606f0e 100644 --- a/eden/scm/lib/manifest/src/tree/mod.rs +++ b/eden/scm/lib/manifest/src/tree/mod.rs @@ -31,7 +31,7 @@ pub(crate) use self::link::Link; pub use self::{diff::Diff, store::TreeStore}; use crate::{ tree::{ - iter::{BfsIter, Cursor, Step}, + iter::{BfsIter, DfsCursor, Step}, link::{DirLink, Durable, DurableEntry, Ephemeral, Leaf}, store::InnerStore, }, @@ -90,8 +90,8 @@ impl Tree { } } - fn root_cursor<'a>(&'a self) -> Cursor<'a> { - Cursor::new(&self.store, RepoPathBuf::new(), &self.root) + fn root_cursor<'a>(&'a self) -> DfsCursor<'a> { + DfsCursor::new(&self.store, RepoPathBuf::new(), &self.root) } } @@ -374,7 +374,7 @@ impl Tree { store: &'a InnerStore, path: RepoPathBuf, converted_nodes: Vec<(RepoPathBuf, HgId, Bytes, HgId, HgId)>, - parent_trees: Vec>, + parent_trees: Vec>, }; impl<'a> Executor<'a> { fn new(store: &'a InnerStore, parent_trees: &[&'a Tree]) -> Result> { @@ -1174,7 +1174,7 @@ mod tests { #[test] fn test_cursor_skip() { - fn step<'a>(cursor: &mut Cursor<'a>) { + fn step<'a>(cursor: &mut DfsCursor<'a>) { match cursor.step() { Step::Success => (), Step::End => panic!("reached the end too soon"),