@@ -26,9 +26,26 @@ result of the evaluation. The existing `prepare(for:)` method is updated to call
26
26
27
27
## Detailed design
28
28
29
- The signature is ` evaluate() async throws -> Evaluation ` , where ` Evaluation ` is
30
- a ` typealias ` for the tuple already used for the callback in ` Kind.conditional ` ,
31
- containing a boolean result and an optional comment.
29
+ The ` evaluate() ` method is as follows, containing essentially the same logic
30
+ as was in ` prepare(for:) ` :
31
+
32
+ ``` swift
33
+ public func evaluate () async throws -> EvaluationResult {
34
+ switch kind {
35
+ case let .conditional (condition):
36
+ try await condition ()
37
+ case let .unconditional (unconditionalValue):
38
+ (unconditionalValue, nil )
39
+ }
40
+ }
41
+ ```
42
+
43
+ ` EvaluationResult ` is a ` typealias ` for the tuple already used as the result
44
+ of the callback in ` Kind.conditional ` :
45
+
46
+ ``` swift
47
+ public typealias EvaluationResult = (wasMet: Bool , comment: Comment? )
48
+ ```
32
49
33
50
## Source compatibility
34
51
@@ -51,7 +68,7 @@ Exposing `ConditionTrait.Kind` and `.kind` was also considered, but it seemed
51
68
unnecessary to go that far, and it would encourage duplicating the logic that
52
69
already exists in ` prepare(for:) ` .
53
70
54
- In the first draft implementation, the ` Evaluation ` type was an enum that only
55
- contained the comment in the failure case. It was changed to match the existing
56
- tuple to allow for potentially including comments for the success case without
57
- requiring a change to the API.
71
+ In the first draft implementation, the ` EvaluationResult ` type was an enum that
72
+ only contained the comment in the failure case. It was changed to match the
73
+ existing tuple to allow for potentially including comments for the success case
74
+ without requiring a change to the API.
0 commit comments