public extension PureYAML.Validation { /// A type-erased `Check`, so checks specialised on different subject types live in one list. It /// filters by runtime type: a `Check` fires only on a `Subject` value, never on an /// optional of it (the `type(of:)` guard) or a value of any other type. struct AnyCheck: Sendable { public let description: String private let applyErased: @Sendable (any Validatable, Path, PureYAML.Model.Value) -> [Issue] public init(_ check: Check) { description = check.description applyErased = { subject, path, document in guard let typed = subject as? Subject, type(of: subject) == Subject.self else { return [] } return check.apply(SubjectContext(document: document, subject: typed, path: path)) } } public func apply( to subject: any Validatable, at path: Path, in document: PureYAML.Model.Value, ) -> [Issue] { applyErased(subject, path, document) } } }