feat: Working on node builder

This commit is contained in:
2024-12-01 01:41:36 -05:00
parent 56a406b231
commit 55d8888961
14 changed files with 480 additions and 39 deletions

View File

@@ -0,0 +1,31 @@
@resultBuilder
public enum NodeBuilder {
public static func buildPartialBlock<N: NodeRepresentable>(first: N) -> N {
first
}
public static func buildPartialBlock<N0: NodeRepresentable, N1: NodeRepresentable>(
accumulated: N0,
next: N1
) -> _ManyNode {
.init([accumulated, next], separator: .empty())
}
public static func buildArray<N: NodeRepresentable>(_ components: [N]) -> _ManyNode {
.init(components, separator: .empty())
}
public static func buildEither<N0: NodeRepresentable, N1: NodeRepresentable>(
first component: N0
) -> _ConditionalNode<N0, N1> {
.first(component)
}
public static func buildEither<N0: NodeRepresentable, N1: NodeRepresentable>(
second component: N1
) -> _ConditionalNode<N0, N1> {
.second(component)
}
}