Files
swift-mirror/stdlib/objc/Foundation/ExtraStringAPIs.swift
Dave Abrahams 39efbb5e17 [stdlib] Add a comment
Swift SVN r23948
2014-12-15 22:24:30 +00:00

24 lines
970 B
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
//
//===----------------------------------------------------------------------===//
// Random access for String.UTF16View, only when Foundation is
// imported. Making this API dependent on Foundation decouples the
// Swift core from a UTF16 representation.
extension String.UTF16View.Index : RandomAccessIndexType {
public func distanceTo(x: String.UTF16View.Index) -> Int {
return x._offset - _offset
}
public func advancedBy(x: Int) -> String.UTF16View.Index {
return String.UTF16View.Index(_offset: _offset + x)
}
}