Skip to content

Commit 4b072f6

Browse files
author
Dave Abrahams
committed
_ isSeparator: => whereSeparator isSeparator:
1 parent b5bc9be commit 4b072f6

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

stdlib/private/StdlibCollectionUnittest/LoggingWrappers.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,13 @@ public struct ${Self}<
274274
public func split(
275275
maxSplits: Int = Int.max,
276276
omittingEmptySubsequences: Bool = true,
277-
isSeparator: @noescape (Base.Iterator.Element) throws -> Bool
277+
whereSeparator isSeparator: @noescape (Base.Iterator.Element) throws -> Bool
278278
) rethrows -> [SubSequence] {
279279
Log.split[selfType] += 1
280280
return try base.split(
281281
maxSplits: maxSplits,
282282
omittingEmptySubsequences: omittingEmptySubsequences,
283-
isSeparator: isSeparator)
283+
whereSeparator: isSeparator)
284284
}
285285

286286
public func _customContainsEquatableElement(

stdlib/public/core/Collection.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,15 +1484,17 @@ extension Collection {
14841484
/// that was originally separated by one or more spaces.
14851485
///
14861486
/// let line = "BLANCHE: I don't want realism. I want magic!"
1487-
/// print(line.characters.split(isSeparator: { $0 == " " })
1487+
/// print(line.characters.split(whereSeparator: { $0 == " " })
14881488
/// .map(String.init))
14891489
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
14901490
///
14911491
/// The second example passes `1` for the `maxSplits` parameter, so the
14921492
/// original string is split just once, into two new strings.
14931493
///
1494-
/// print(line.characters.split(maxSplits: 1, isSeparator: { $0 == " " })
1495-
/// .map(String.init))
1494+
/// print(
1495+
/// line.characters.split(
1496+
/// maxSplits: 1, whereSeparator: { $0 == " " }
1497+
/// ).map(String.init))
14961498
/// // Prints "["BLANCHE:", " I don\'t want realism. I want magic!"]"
14971499
///
14981500
/// The final example passes `false` for the `omittingEmptySubsequences`
@@ -1523,7 +1525,7 @@ extension Collection {
15231525
public func split(
15241526
maxSplits: Int = Int.max,
15251527
omittingEmptySubsequences: Bool = true,
1526-
isSeparator: @noescape (Iterator.Element) throws -> Bool
1528+
whereSeparator isSeparator: @noescape (Iterator.Element) throws -> Bool
15271529
) rethrows -> [SubSequence] {
15281530
// TODO: swift-3-indexing-model - review the following
15291531
_precondition(maxSplits >= 0, "Must take zero or more splits")
@@ -1624,7 +1626,7 @@ extension Collection where Iterator.Element : Equatable {
16241626
return split(
16251627
maxSplits: maxSplits,
16261628
omittingEmptySubsequences: omittingEmptySubsequences,
1627-
isSeparator: { $0 == separator })
1629+
whereSeparator: { $0 == separator })
16281630
}
16291631
}
16301632

@@ -1719,11 +1721,11 @@ extension Collection {
17191721
Builtin.unreachable()
17201722
}
17211723

1722-
@available(*, unavailable, message: "Please use split(maxSplits:omittingEmptySubsequences:isSeparator:) instead")
1724+
@available(*, unavailable, message: "Please use split(maxSplits:omittingEmptySubsequences:whereSeparator:) instead")
17231725
public func split(
17241726
_ maxSplit: Int = Int.max,
17251727
allowEmptySlices: Bool = false,
1726-
isSeparator: @noescape (Iterator.Element) throws -> Bool
1728+
whereSeparator isSeparator: @noescape (Iterator.Element) throws -> Bool
17271729
) rethrows -> [SubSequence] {
17281730
Builtin.unreachable()
17291731
}

stdlib/public/core/ExistentialCollection.swift.gyb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ internal class _AnyRandomAccessCollectionBox<Element>
200200

201201
internal func _split(
202202
maxSplits: Int, omittingEmptySubsequences: Bool,
203-
isSeparator: @noescape (Element) throws -> Bool
203+
whereSeparator isSeparator: @noescape (Element) throws -> Bool
204204
) rethrows -> [Any${Kind}<Element>] {
205205
_abstract()
206206
}
@@ -376,12 +376,12 @@ internal final class _${Kind}Box<S : ${Kind}> : _Any${Kind}Box<S.Iterator.Elemen
376376
% for ResultKind in EqualAndWeakerKinds:
377377
internal override func _split(
378378
maxSplits: Int, omittingEmptySubsequences: Bool,
379-
isSeparator: @noescape (Element) throws -> Bool
379+
whereSeparator isSeparator: @noescape (Element) throws -> Bool
380380
) rethrows -> [Any${ResultKind}<Element>] {
381381
return try _base.split(
382382
maxSplits: maxSplits,
383383
omittingEmptySubsequences: omittingEmptySubsequences,
384-
isSeparator: isSeparator)
384+
whereSeparator: isSeparator)
385385
.map {
386386
Any${ResultKind}(_box: _${Kind}Box<S.SubSequence>(_base: $0))
387387
}
@@ -609,12 +609,12 @@ extension Any${Kind} {
609609
public func split(
610610
maxSplits: Int = Int.max,
611611
omittingEmptySubsequences: Bool = true,
612-
isSeparator: @noescape (Element) throws -> Bool
612+
whereSeparator isSeparator: @noescape (Element) throws -> Bool
613613
) rethrows -> [Any${Kind}<Element>] {
614614
return try _box._split(
615615
maxSplits: maxSplits,
616616
omittingEmptySubsequences: omittingEmptySubsequences,
617-
isSeparator: isSeparator)
617+
whereSeparator: isSeparator)
618618
}
619619

620620
public func _preprocessingPass<R>(

stdlib/public/core/Sequence.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public protocol Sequence {
558558
/// - Returns: An array of subsequences, split from this sequence's elements.
559559
func split(
560560
maxSplits: Int, omittingEmptySubsequences: Bool,
561-
isSeparator: @noescape (Iterator.Element) throws -> Bool
561+
whereSeparator isSeparator: @noescape (Iterator.Element) throws -> Bool
562562
) rethrows -> [SubSequence]
563563

564564
/// Returns the first element of the sequence that satisfies the given
@@ -859,7 +859,7 @@ extension Sequence {
859859
public func split(
860860
maxSplits: Int = Int.max,
861861
omittingEmptySubsequences: Bool = true,
862-
isSeparator: @noescape (Iterator.Element) throws -> Bool
862+
whereSeparator isSeparator: @noescape (Iterator.Element) throws -> Bool
863863
) rethrows -> [AnySequence<Iterator.Element>] {
864864
_precondition(maxSplits >= 0, "Must take zero or more splits")
865865
var result: [AnySequence<Iterator.Element>] = []
@@ -1043,7 +1043,7 @@ extension Sequence where Iterator.Element : Equatable {
10431043
return split(
10441044
maxSplits: maxSplits,
10451045
omittingEmptySubsequences: omittingEmptySubsequences,
1046-
isSeparator: { $0 == separator })
1046+
whereSeparator: { $0 == separator })
10471047
}
10481048
}
10491049

test/1_stdlib/Renames.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func _Collection<C : Collection>(c: C) {
6161
func fn<T : Collection, U>(_: T, _: U) where T.Generator == U {} // expected-error {{'T' does not have a member type named 'Generator'; did you mean 'Iterator'?}} {{50-59=Iterator}} {{none}}
6262
_ = c.generate() // expected-error {{'generate()' has been renamed to 'makeIterator()'}} {{9-17=makeIterator}} {{none}}
6363
_ = c.underestimateCount() // expected-error {{'underestimateCount()' is unavailable: Removed in Swift 3. Please use underestimatedCount property.}} {{none}}
64-
_ = c.split(1) { _ in return true} // expected-error {{'split(_:allowEmptySlices:isSeparator:)' is unavailable: Please use split(maxSplits:omittingEmptySubsequences:isSeparator:) instead}} {{none}}
64+
_ = c.split(1) { _ in return true} // expected-error {{split(maxSplits:omittingEmptySubsequences:whereSeparator:) instead}} {{none}}
6565
}
6666

6767
func _Collection<C : Collection, E>(c: C, e: E) where C.Iterator.Element: Equatable, C.Iterator.Element == E {

test/Constraints/diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func r22020088bar(_ p: r22020088P?) {
554554

555555
// <rdar://problem/22288575> QoI: poor diagnostic involving closure, bad parameter label, and mismatch return type
556556
func f(_ arguments: [String]) -> [ArraySlice<String>] {
557-
return arguments.split(maxSplits: 1, omittingEmptySubsequences: false, isSeparator: { $0 == "--" })
557+
return arguments.split(maxSplits: 1, omittingEmptySubsequences: false, whereSeparator: { $0 == "--" })
558558
}
559559

560560

0 commit comments

Comments
 (0)