-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependencyBuilder.swift
More file actions
18 lines (17 loc) · 949 Bytes
/
DependencyBuilder.swift
File metadata and controls
18 lines (17 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// A builder for creating collections of `Dependency` instances.
@resultBuilder
public enum DependencyBuilder {
/// Builds a partial block of dependencies, consisting of a single `Dependency`.
/// - Parameter first: The first `Dependency` in the block.
/// - Returns: An array containing the `first` `Dependency`.
public static func buildPartialBlock(first: Dependency) -> any Dependencies {
[first]
}
/// Builds a partial block of dependencies, adding a new `Dependency` to an existing collection.
/// - Parameter accumulated: The existing collection of dependencies.
/// - Parameter next: The new `Dependency` to add to the collection.
/// - Returns: A new collection of dependencies, containing the accumulated dependencies and the `next` dependency.
public static func buildPartialBlock(accumulated: any Dependencies, next: Dependency) -> any Dependencies {
accumulated + [next]
}
}