Files
swift-mirror/stdlib/objc/Foundation/MixedStringNSStringOperations.swift.gyb
2014-07-25 18:32:36 +00:00

42 lines
1.2 KiB
Swift

//===--- MixedStringNSStringOperations.swift.gyb --------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Mixed-type comparisons between String and NSString.
//
% for op in [ '==', '!=', '<', '<=', '>=', '>' ]:
@transparent
public func ${op} (lhs: String, rhs: NSString) -> Bool {
// FIXME(performance): constructing a temporary string is extremely
// wasteful and inefficient.
return lhs ${op} (rhs as String)
}
@transparent
public func ${op} (lhs: NSString, rhs: String) -> Bool {
// FIXME(performance): constructing a temporary string is extremely
// wasteful and inefficient.
return (lhs as String) ${op} rhs
}
% end
// This overload is required to disambiguate homogeneous NSString/NSString
// comparisons in non-generic code.
@transparent
public func != (lhs: NSString, rhs: NSString) -> Bool {
return !(lhs == rhs)
}