Advertisement
Revolucent

Generics!

Apr 13th, 2018
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.11 KB | None | 0 0
  1. public func `in`<Expressions: Sequence>(_ lhs: Expression, _ rhs: Expressions, options: NSComparisonPredicate.Options = .caseInsensitive, modifier: NSComparisonPredicate.Modifier = .any) -> NSPredicate where Expressions.Element: Expression {
  2.     return NSComparisonPredicate(leftExpression: lhs.cdqiExpression, rightExpression: NSExpression(forAggregate: rhs.map(\.cdqiExpression)), modifier: modifier, type: .in, options: options)
  3. }
  4.  
  5. public func ==<L: Expression & Inconstant & TypeComparable, R: Expression & TypeComparable, Expressions: Sequence>(lhs: L, rhs: Expressions) -> NSPredicate where L.CDQIComparableType == R.CDQIComparableType, Expressions.Element == R {
  6.     return `in`(lhs, rhs)
  7. }
  8.  
  9. public extension Expression where Self: TypeComparable {
  10.     func cdqiIn<Expressions: Sequence, E: Expression & TypeComparable>(_ rhs: Expressions, options: NSComparisonPredicate.Options = .caseInsensitive, modifier: NSComparisonPredicate.Modifier = .any) -> NSPredicate where Expressions.Element == E, CDQIComparableType == E.CDQIComparableType {
  11.         return `in`(self, rhs, options: options, modifier: modifier)
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement