@@ -15,6 +15,8 @@ impl<'repo> Tree<'repo> {
15
15
pub struct Platform < ' a , ' repo > {
16
16
root : & ' a Tree < ' repo > ,
17
17
/// Provides easy access to presets for common breadth-first traversal.
18
+ // TODO: remove this - it's a bit too much of a fixed function, or go all in once it's clear it's needed,
19
+ // but probably with depth-first.
18
20
pub breadthfirst : BreadthFirstPresets < ' a , ' repo > ,
19
21
}
20
22
@@ -38,12 +40,12 @@ impl BreadthFirstPresets<'_, '_> {
38
40
}
39
41
40
42
impl Platform < ' _ , ' _ > {
41
- /// Start a breadth-first, recursive traversal using `delegate`, for which a [`Recorder`][ gix_traverse::tree::Recorder] can be used to get started.
43
+ /// Start a breadth-first, recursive traversal using `delegate`, for which a [`Recorder`]( gix_traverse::tree::Recorder) can be used to get started.
42
44
///
43
45
/// # Note
44
46
///
45
- /// - Results are returned in sort order according to tree-entry sorting rules, one level at a time.
46
- /// - for obtaining the direct children of the tree, use [.iter()][crate:: Tree::iter()] instead.
47
+ /// - Results are returned in sort order as per tree-sorting rules, files first, then directories , one level at a time.
48
+ /// - for obtaining the direct children of the tree, use [Tree::iter()] instead.
47
49
pub fn breadthfirst < V > ( & self , delegate : & mut V ) -> Result < ( ) , gix_traverse:: tree:: breadthfirst:: Error >
48
50
where
49
51
V : gix_traverse:: tree:: Visit ,
@@ -52,4 +54,17 @@ impl Platform<'_, '_> {
52
54
let state = gix_traverse:: tree:: breadthfirst:: State :: default ( ) ;
53
55
gix_traverse:: tree:: breadthfirst ( root, state, & self . root . repo . objects , delegate)
54
56
}
57
+
58
+ /// Start a depth-first, recursive traversal using `delegate`, for which a [`Recorder`](gix_traverse::tree::Recorder) can be used to get started.
59
+ ///
60
+ /// # Note
61
+ ///
62
+ /// For obtaining the direct children of the tree, use [Tree::iter()] instead.
63
+ pub fn depthfirst < V > ( & self , delegate : & mut V ) -> Result < ( ) , gix_traverse:: tree:: breadthfirst:: Error >
64
+ where
65
+ V : gix_traverse:: tree:: Visit ,
66
+ {
67
+ let state = gix_traverse:: tree:: depthfirst:: State :: default ( ) ;
68
+ gix_traverse:: tree:: depthfirst ( self . root . id , state, & self . root . repo . objects , delegate)
69
+ }
55
70
}
0 commit comments