init(_:)
Creates an evaluator with the given evaluation closure.
Declaration
init(_ evaluate: nonisolated(nonsending) @escaping (Input, ModelSubject<Input.ExpectedValue>) async throws -> Metric)Parameters
- evaluate:
A closure that receives the input and subject, and returns a Metric with a result value.
Discussion
let metric = Metric("ExactMatch")
let evaluator = Evaluator<ModelSample<String>> { sample, subject in
guard let expected = sample.expected else { return metric.ignore() }
return subject.value == expected ? metric.passing() : metric.failing()
}