feat: Working on node builder
This commit is contained in:
31
Sources/CliDoc/NodeBuilder.swift
Normal file
31
Sources/CliDoc/NodeBuilder.swift
Normal 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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user