mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
This commit is contained in:
@@ -26,7 +26,7 @@ extension String.Index {
|
||||
/// print(cafe)
|
||||
/// // Prints "Café"
|
||||
///
|
||||
/// let scalarsIndex = cafe.unicodeScalars.index(of: "e")!
|
||||
/// let scalarsIndex = cafe.unicodeScalars.firstIndex(of: "e")!
|
||||
/// let stringIndex = String.Index(scalarsIndex, within: cafe)!
|
||||
///
|
||||
/// print(cafe[...stringIndex])
|
||||
@@ -67,7 +67,7 @@ extension String.Index {
|
||||
/// uses this method find the same position in the string's `utf8` view.
|
||||
///
|
||||
/// let cafe = "Café"
|
||||
/// if let i = cafe.index(of: "é") {
|
||||
/// if let i = cafe.firstIndex(of: "é") {
|
||||
/// let j = i.samePosition(in: cafe.utf8)!
|
||||
/// print(Array(cafe.utf8[j...]))
|
||||
/// }
|
||||
@@ -96,7 +96,7 @@ extension String.Index {
|
||||
/// uses this method find the same position in the string's `utf16` view.
|
||||
///
|
||||
/// let cafe = "Café"
|
||||
/// if let i = cafe.index(of: "é") {
|
||||
/// if let i = cafe.firstIndex(of: "é") {
|
||||
/// let j = i.samePosition(in: cafe.utf16)!
|
||||
/// print(cafe.utf16[j])
|
||||
/// }
|
||||
|
||||
Reference in New Issue
Block a user