mirror of
https://github.com/apple/swift-foundation.git
synced 2025-05-25 23:48:33 +08:00
51 lines
1.8 KiB
Swift
51 lines
1.8 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2022-2023 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
extension PredicateExpressions {
|
|
public struct Equal<
|
|
LHS : PredicateExpression,
|
|
RHS : PredicateExpression
|
|
> : PredicateExpression
|
|
where
|
|
LHS.Output == RHS.Output,
|
|
LHS.Output : Equatable
|
|
{
|
|
public typealias Output = Bool
|
|
|
|
public let lhs: LHS
|
|
public let rhs: RHS
|
|
|
|
public init(lhs: LHS, rhs: RHS) {
|
|
self.lhs = lhs
|
|
self.rhs = rhs
|
|
}
|
|
|
|
public func evaluate(_ bindings: PredicateBindings) throws -> Bool {
|
|
try lhs.evaluate(bindings) == rhs.evaluate(bindings)
|
|
}
|
|
}
|
|
|
|
public static func build_Equal<LHS, RHS>(lhs: LHS, rhs: RHS) -> Equal<LHS, RHS> {
|
|
Equal(lhs: lhs, rhs: rhs)
|
|
}
|
|
}
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
extension PredicateExpressions.Equal : StandardPredicateExpression where LHS : StandardPredicateExpression, RHS : StandardPredicateExpression {}
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
extension PredicateExpressions.Equal : Codable where LHS : Codable, RHS : Codable {}
|
|
|
|
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
|
extension PredicateExpressions.Equal : Sendable where LHS : Sendable, RHS : Sendable {}
|