Refactor: streamline Node.WithParents()

Make it take parameters just like all the callers have, instead of
making them create a different structure.

It is now only used in tests.
This commit is contained in:
Bryan Boreham
2018-07-20 19:57:44 +00:00
parent 67052a6580
commit 1ed07f4a0a
5 changed files with 112 additions and 175 deletions

View File

@@ -169,14 +169,8 @@ func (n Node) PruneParents() Node {
}
// WithChildren returns a fresh copy of n, with children merged in.
func (n Node) WithChildren(children NodeSet) Node {
n.Children = n.Children.Merge(children)
return n
}
// WithChild returns a fresh copy of n, with one child merged in.
func (n Node) WithChild(child Node) Node {
n.Children = n.Children.Merge(MakeNodeSet(child))
func (n Node) WithChildren(children ...Node) Node {
n.Children = n.Children.Add(children...)
return n
}