mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Make our BidirectionalIndexTypes Comparable
This will allow more error checking, resilient slicing, and occasionally other useful capabilities. Step 1 of <rdar://problem/11940897> Swift SVN r20036
This commit is contained in:
@@ -17,6 +17,13 @@ public func ==(
|
||||
return lhs._position == rhs._position
|
||||
}
|
||||
|
||||
public func <(
|
||||
lhs: String.UnicodeScalarView.Index,
|
||||
rhs: String.UnicodeScalarView.Index
|
||||
) -> Bool {
|
||||
return lhs._position < rhs._position
|
||||
}
|
||||
|
||||
extension String {
|
||||
public struct UnicodeScalarView : Sliceable, SequenceType {
|
||||
init(_ _core: _StringCore) {
|
||||
@@ -38,7 +45,7 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
public struct Index : BidirectionalIndexType {
|
||||
public struct Index : BidirectionalIndexType, Comparable {
|
||||
public init(_ _position: Int, _ _core: _StringCore) {
|
||||
self._position = _position
|
||||
self._core = _core
|
||||
|
||||
Reference in New Issue
Block a user