[stdlib] Rename index(...) methods to firstIndex(...)

A la SE-204.
This commit is contained in:
Nate Cook
2017-10-19 11:05:48 -05:00
parent 67852ed460
commit 58933d88c5
45 changed files with 200 additions and 175 deletions

View File

@@ -55,7 +55,7 @@ extension String {
/// `String` type's `init(_:)` initializer.
///
/// let favemoji = "My favorite emoji is 🎉"
/// if let i = favemoji.utf16.index(where: { $0 >= 128 }) {
/// if let i = favemoji.utf16.firstIndex(where: { $0 >= 128 }) {
/// let asciiPrefix = String(favemoji.utf16[..<i])
/// print(asciiPrefix)
/// }
@@ -303,7 +303,7 @@ extension String {
/// another string's `utf16` view.
///
/// let picnicGuest = "Deserving porcupine"
/// if let i = picnicGuest.utf16.index(of: 32) {
/// if let i = picnicGuest.utf16.firstIndex(of: 32) {
/// let adjective = String(picnicGuest.utf16[..<i])
/// print(adjective)
/// }
@@ -379,7 +379,7 @@ extension String.UTF16View.Index {
///
/// let cafe = "Café 🍵"
///
/// let stringIndex = cafe.index(of: "é")!
/// let stringIndex = cafe.firstIndex(of: "é")!
/// let utf16Index = String.Index(stringIndex, within: cafe.utf16)!
///
/// print(cafe.utf16[...utf16Index])
@@ -407,7 +407,7 @@ extension String.UTF16View.Index {
/// position in the string's `unicodeScalars` view.
///
/// let cafe = "Café 🍵"
/// let i = cafe.utf16.index(of: 32)!
/// let i = cafe.utf16.firstIndex(of: 32)!
/// let j = i.samePosition(in: cafe.unicodeScalars)!
/// print(cafe.unicodeScalars[..<j])
/// // Prints "Café"