|
7 | 7 | /// See ``CombineReducers`` for an entry point into a reducer builder context.
|
8 | 8 | @resultBuilder
|
9 | 9 | public enum ReducerBuilder<State, Action> {
|
10 |
| - #if swift(>=5.7) |
11 |
| - @inlinable |
12 |
| - public static func buildArray( |
13 |
| - _ reducers: [some ReducerProtocol<State, Action>] |
14 |
| - ) -> some ReducerProtocol<State, Action> { |
15 |
| - _SequenceMany(reducers: reducers) |
16 |
| - } |
17 |
| - |
18 |
| - @inlinable |
19 |
| - public static func buildBlock() -> some ReducerProtocol<State, Action> { |
20 |
| - EmptyReducer() |
21 |
| - } |
22 |
| - |
23 |
| - @inlinable |
24 |
| - public static func buildBlock( |
25 |
| - _ reducer: some ReducerProtocol<State, Action> |
26 |
| - ) -> some ReducerProtocol<State, Action> { |
27 |
| - reducer |
28 |
| - } |
| 10 | + @inlinable |
| 11 | + public static func buildArray<R: ReducerProtocol>(_ reducers: [R]) -> _SequenceMany<R> |
| 12 | + where R.State == State, R.Action == Action { |
| 13 | + _SequenceMany(reducers: reducers) |
| 14 | + } |
29 | 15 |
|
30 |
| - @inlinable |
31 |
| - public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>( |
32 |
| - first reducer: R0 |
33 |
| - ) -> _Conditional<R0, R1> |
34 |
| - where R0.State == State, R0.Action == Action, R1.State == State, R1.Action == Action { |
35 |
| - .first(reducer) |
36 |
| - } |
| 16 | + @inlinable |
| 17 | + public static func buildBlock() -> EmptyReducer<State, Action> { |
| 18 | + EmptyReducer() |
| 19 | + } |
37 | 20 |
|
38 |
| - @inlinable |
39 |
| - public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>( |
40 |
| - second reducer: R1 |
41 |
| - ) -> _Conditional<R0, R1> |
42 |
| - where R0.State == State, R0.Action == Action, R1.State == State, R1.Action == Action { |
43 |
| - .second(reducer) |
44 |
| - } |
| 21 | + @inlinable |
| 22 | + public static func buildBlock<R: ReducerProtocol>(_ reducer: R) -> R |
| 23 | + where R.State == State, R.Action == Action { |
| 24 | + reducer |
| 25 | + } |
45 | 26 |
|
46 |
| - @inlinable |
47 |
| - public static func buildExpression( |
48 |
| - _ expression: some ReducerProtocol<State, Action> |
49 |
| - ) -> some ReducerProtocol<State, Action> { |
50 |
| - expression |
51 |
| - } |
| 27 | + @inlinable |
| 28 | + public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>( |
| 29 | + first reducer: R0 |
| 30 | + ) -> _Conditional<R0, R1> |
| 31 | + where R0.State == State, R0.Action == Action, R1.State == State, R1.Action == Action { |
| 32 | + .first(reducer) |
| 33 | + } |
52 | 34 |
|
53 |
| - @inlinable |
54 |
| - public static func buildFinalResult( |
55 |
| - _ reducer: some ReducerProtocol<State, Action> |
56 |
| - ) -> some ReducerProtocol<State, Action> { |
57 |
| - reducer |
58 |
| - } |
| 35 | + @inlinable |
| 36 | + public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>( |
| 37 | + second reducer: R1 |
| 38 | + ) -> _Conditional<R0, R1> |
| 39 | + where R0.State == State, R0.Action == Action, R1.State == State, R1.Action == Action { |
| 40 | + .second(reducer) |
| 41 | + } |
59 | 42 |
|
60 |
| - @inlinable |
61 |
| - public static func buildLimitedAvailability( |
62 |
| - _ wrapped: some ReducerProtocol<State, Action> |
63 |
| - ) -> Reduce<State, Action> { |
64 |
| - Reduce(wrapped) |
65 |
| - } |
| 43 | + @inlinable |
| 44 | + public static func buildExpression<R: ReducerProtocol>(_ expression: R) -> R |
| 45 | + where R.State == State, R.Action == Action { |
| 46 | + expression |
| 47 | + } |
66 | 48 |
|
67 |
| - @inlinable |
68 |
| - public static func buildOptional( |
69 |
| - _ wrapped: (some ReducerProtocol<State, Action>)? |
70 |
| - ) -> some ReducerProtocol<State, Action> { |
71 |
| - wrapped |
72 |
| - } |
| 49 | + @inlinable |
| 50 | + public static func buildFinalResult<R: ReducerProtocol>(_ reducer: R) -> R |
| 51 | + where R.State == State, R.Action == Action { |
| 52 | + reducer |
| 53 | + } |
73 | 54 |
|
74 |
| - @inlinable |
75 |
| - public static func buildPartialBlock( |
76 |
| - first: some ReducerProtocol<State, Action> |
77 |
| - ) -> some ReducerProtocol<State, Action> { |
78 |
| - first |
79 |
| - } |
| 55 | + @inlinable |
| 56 | + public static func buildLimitedAvailability<R: ReducerProtocol>( |
| 57 | + _ wrapped: R |
| 58 | + ) -> Reduce<State, Action> |
| 59 | + where R.State == State, R.Action == Action { |
| 60 | + Reduce(wrapped) |
| 61 | + } |
80 | 62 |
|
81 |
| - @inlinable |
82 |
| - public static func buildPartialBlock( |
83 |
| - accumulated: some ReducerProtocol<State, Action>, next: some ReducerProtocol<State, Action> |
84 |
| - ) -> some ReducerProtocol<State, Action> { |
85 |
| - _Sequence(accumulated, next) |
86 |
| - } |
87 |
| - #else |
88 |
| - @inlinable |
89 |
| - public static func buildArray<R: ReducerProtocol>(_ reducers: [R]) -> _SequenceMany<R> |
90 |
| - where R.State == State, R.Action == Action { |
91 |
| - _SequenceMany(reducers: reducers) |
92 |
| - } |
| 63 | + @inlinable |
| 64 | + public static func buildOptional<R: ReducerProtocol>(_ wrapped: R?) -> R? |
| 65 | + where R.State == State, R.Action == Action { |
| 66 | + wrapped |
| 67 | + } |
93 | 68 |
|
94 |
| - @inlinable |
95 |
| - public static func buildBlock() -> EmptyReducer<State, Action> { |
96 |
| - EmptyReducer() |
97 |
| - } |
| 69 | + @inlinable |
| 70 | + public static func buildPartialBlock<R: ReducerProtocol>( |
| 71 | + first: R |
| 72 | + ) -> R |
| 73 | + where R.State == State, R.Action == Action { |
| 74 | + first |
| 75 | + } |
98 | 76 |
|
99 |
| - @inlinable |
100 |
| - public static func buildBlock<R: ReducerProtocol>(_ reducer: R) -> R |
101 |
| - where R.State == State, R.Action == Action { |
102 |
| - reducer |
103 |
| - } |
| 77 | + @inlinable |
| 78 | + public static func buildPartialBlock<R0: ReducerProtocol, R1: ReducerProtocol>( |
| 79 | + accumulated: R0, next: R1 |
| 80 | + ) -> _Sequence<R0, R1> |
| 81 | + where R0.State == State, R0.Action == Action, R1.State == State, R1.Action == Action { |
| 82 | + _Sequence(accumulated, next) |
| 83 | + } |
104 | 84 |
|
| 85 | + #if swift(<5.7) |
105 | 86 | @inlinable
|
106 | 87 | public static func buildBlock<
|
107 | 88 | R0: ReducerProtocol,
|
@@ -330,54 +311,12 @@ public enum ReducerBuilder<State, Action> {
|
330 | 311 | )
|
331 | 312 | }
|
332 | 313 |
|
333 |
| - @inlinable |
334 |
| - public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>( |
335 |
| - first reducer: R0 |
336 |
| - ) -> _Conditional<R0, R1> |
337 |
| - where R0.State == State, R0.Action == Action { |
338 |
| - .first(reducer) |
339 |
| - } |
340 |
| - |
341 |
| - @inlinable |
342 |
| - public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>( |
343 |
| - second reducer: R1 |
344 |
| - ) -> _Conditional<R0, R1> |
345 |
| - where R1.State == State, R1.Action == Action { |
346 |
| - .second(reducer) |
347 |
| - } |
348 |
| - |
349 |
| - @inlinable |
350 |
| - public static func buildExpression<R: ReducerProtocol>(_ expression: R) -> R |
351 |
| - where R.State == State, R.Action == Action { |
352 |
| - expression |
353 |
| - } |
354 |
| - |
355 |
| - @inlinable |
356 |
| - public static func buildFinalResult<R: ReducerProtocol>(_ reducer: R) -> R |
357 |
| - where R.State == State, R.Action == Action { |
358 |
| - reducer |
359 |
| - } |
360 |
| - |
361 | 314 | @_disfavoredOverload
|
362 | 315 | @inlinable
|
363 | 316 | public static func buildFinalResult<R: ReducerProtocol>(_ reducer: R) -> Reduce<State, Action>
|
364 | 317 | where R.State == State, R.Action == Action {
|
365 | 318 | Reduce(reducer)
|
366 | 319 | }
|
367 |
| - |
368 |
| - @inlinable |
369 |
| - public static func buildLimitedAvailability<R: ReducerProtocol>( |
370 |
| - _ wrapped: R |
371 |
| - ) -> Reduce<R.State, R.Action> |
372 |
| - where R.State == State, R.Action == Action { |
373 |
| - Reduce(wrapped) |
374 |
| - } |
375 |
| - |
376 |
| - @inlinable |
377 |
| - public static func buildOptional<R: ReducerProtocol>(_ wrapped: R?) -> R? |
378 |
| - where R.State == State, R.Action == Action { |
379 |
| - wrapped |
380 |
| - } |
381 | 320 | #endif
|
382 | 321 |
|
383 | 322 | public enum _Conditional<First: ReducerProtocol, Second: ReducerProtocol>: ReducerProtocol
|
@@ -440,5 +379,3 @@ public enum ReducerBuilder<State, Action> {
|
440 | 379 | }
|
441 | 380 | }
|
442 | 381 | }
|
443 |
| - |
444 |
| -public typealias ReducerBuilderOf<R: ReducerProtocol> = ReducerBuilder<R.State, R.Action> |
0 commit comments