Skip to content

Commit 3852de6

Browse files
committed
Impl topo::Builder::from_iters with new, with_tips and with_ends
Previously, the only way to create a `Builder` would be via `Builder::from_iters`. That fn takes as arguments both the tips and ends, and used to be the only possibility for specifying either of them during the building process. However, in order to enhance the builder- likeness of `Builder`, we recently introduced various fns allowing for alternative build flows. This fn reduces code duplication by using those new fns for implementing `from_iters`.
1 parent 59148a2 commit 3852de6

File tree

1 file changed

+5
-14
lines changed
  • gix-traverse/src/commit/topo

1 file changed

+5
-14
lines changed

gix-traverse/src/commit/topo/init.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,11 @@ where
2828
tips: impl IntoIterator<Item = impl Into<ObjectId>>,
2929
ends: Option<impl IntoIterator<Item = impl Into<ObjectId>>>,
3030
) -> Self {
31-
let tips = tips.into_iter().map(Into::into).collect::<Vec<_>>();
32-
let ends = ends
33-
.map(|e| e.into_iter().map(Into::into).collect::<Vec<_>>())
34-
.unwrap_or_default();
35-
36-
Self {
37-
commit_graph: Default::default(),
38-
find,
39-
sorting: Default::default(),
40-
parents: Default::default(),
41-
tips,
42-
ends,
43-
predicate: |_| true,
44-
}
31+
let mut builder = Self::new(find).with_tips(tips);
32+
if let Some(ends) = ends {
33+
builder = builder.with_ends(ends)
34+
};
35+
builder
4536
}
4637

4738
/// Create a new `Builder` for a [`Topo`] that reads commits from a

0 commit comments

Comments
 (0)