Skip to content

Commit a88f028

Browse files
authored
Merge pull request #3258 from natecook1000/swift-3.0-preview-2-branch
[swift-3.0-preview-2-branch] Fix stdlib documentation errors
2 parents 6571472 + ae9497d commit a88f028

File tree

3 files changed

+71
-54
lines changed

3 files changed

+71
-54
lines changed

stdlib/public/core/Collection.swift

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,6 @@ extension Collection where SubSequence == Slice<Self> {
11441144
}
11451145
}
11461146

1147-
// TODO: swift-3-indexing-model - review the following
11481147
extension Collection where SubSequence == Self {
11491148
/// Removes and returns the first element of the collection.
11501149
///
@@ -1153,6 +1152,7 @@ extension Collection where SubSequence == Self {
11531152
///
11541153
/// - Complexity: O(1)
11551154
public mutating func popFirst() -> Iterator.Element? {
1155+
// TODO: swift-3-indexing-model - review the following
11561156
guard !isEmpty else { return nil }
11571157
let element = first!
11581158
self = self[index(after: startIndex)..<endIndex]
@@ -1200,21 +1200,22 @@ extension Collection {
12001200
var i = makeIterator()
12011201
return i.next()
12021202
}
1203-
// TODO: swift-3-indexing-model - uncomment and replace above ready (or should we still use the iterator one?)
1203+
1204+
// TODO: swift-3-indexing-model - uncomment and replace above ready (or should we still use the iterator one?)
12041205
/// Returns the first element of `self`, or `nil` if `self` is empty.
12051206
///
12061207
/// - Complexity: O(1)
12071208
// public var first: Iterator.Element? {
12081209
// return isEmpty ? nil : self[startIndex]
12091210
// }
12101211

1211-
// TODO: swift-3-indexing-model - review the following
12121212
/// A value less than or equal to the number of elements in the collection.
12131213
///
12141214
/// - Complexity: O(1) if the collection conforms to
12151215
/// `RandomAccessCollection`; otherwise, O(*n*), where *n* is the length
12161216
/// of the collection.
12171217
public var underestimatedCount: Int {
1218+
// TODO: swift-3-indexing-model - review the following
12181219
return numericCast(count)
12191220
}
12201221

@@ -1227,7 +1228,7 @@ extension Collection {
12271228
return distance(from: startIndex, to: endIndex)
12281229
}
12291230

1230-
// TODO: swift-3-indexing-model - rename the following to _customIndexOfEquatable(element)?
1231+
// TODO: swift-3-indexing-model - rename the following to _customIndexOfEquatable(element)?
12311232
/// Customization point for `Collection.index(of:)`.
12321233
///
12331234
/// Define this method if the collection can find an element in less than
@@ -1249,7 +1250,6 @@ extension Collection {
12491250
//===----------------------------------------------------------------------===//
12501251

12511252
extension Collection {
1252-
// TODO: swift-3-indexing-model - review the following
12531253
/// Returns an array containing the results of mapping the given closure
12541254
/// over the sequence's elements.
12551255
///
@@ -1270,6 +1270,7 @@ extension Collection {
12701270
public func map<T>(
12711271
_ transform: @noescape (Iterator.Element) throws -> T
12721272
) rethrows -> [T] {
1273+
// TODO: swift-3-indexing-model - review the following
12731274
let count: Int = numericCast(self.count)
12741275
if count == 0 {
12751276
return []
@@ -1474,10 +1475,12 @@ extension Collection {
14741475
return prefix(upTo: index(after: position))
14751476
}
14761477

1477-
// TODO: swift-3-indexing-model - review the following
1478-
/// Returns the longest possible subsequences of the sequence, in order, that
1479-
/// don't contain elements satisfying the given predicate. Elements that are
1480-
/// used to split the sequence are not returned as part of any subsequence.
1478+
/// Returns the longest possible subsequences of the collection, in order,
1479+
/// that don't contain elements satisfying the given predicate.
1480+
///
1481+
/// The resulting array consists of at most `maxSplits + 1` subsequences.
1482+
/// Elements that are used to split the sequence are not returned as part of
1483+
/// any subsequence.
14811484
///
14821485
/// The following examples show the effects of the `maxSplits` and
14831486
/// `omittingEmptySubsequences` parameters when splitting a string using a
@@ -1487,7 +1490,7 @@ extension Collection {
14871490
/// let line = "BLANCHE: I don't want realism. I want magic!"
14881491
/// print(line.characters.split(isSeparator: { $0 == " " })
14891492
/// .map(String.init))
1490-
/// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
1493+
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
14911494
///
14921495
/// The second example passes `1` for the `maxSplits` parameter, so the
14931496
/// original string is split just once, into two new strings.
@@ -1505,24 +1508,28 @@ extension Collection {
15051508
/// // Prints "["BLANCHE:", "", "", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
15061509
///
15071510
/// - Parameters:
1508-
/// - maxSplits: The maximum number of times to split the sequence, or one
1509-
/// less than the number of subsequences to return. If `maxSplits + 1`
1510-
/// subsequences are returned, the last one is a suffix of the original
1511-
/// sequence containing the remaining elements. `maxSplits` must be
1512-
/// greater than or equal to zero.
1511+
/// - maxSplits: The maximum number of times to split the collection, or
1512+
/// one less than the number of subsequences to return. If
1513+
/// `maxSplits + 1` subsequences are returned, the last one is a suffix
1514+
/// of the original collection containing the remaining elements.
1515+
/// `maxSplits` must be greater than or equal to zero. The default value
1516+
/// is `Int.max`.
15131517
/// - omittingEmptySubsequences: If `false`, an empty subsequence is
15141518
/// returned in the result for each pair of consecutive elements
15151519
/// satisfying the `isSeparator` predicate and for each element at the
1516-
/// start or end of the sequence satisfying the `isSeparator` predicate.
1520+
/// start or end of the collection satisfying the `isSeparator`
1521+
/// predicate. The default value is `true`.
15171522
/// - isSeparator: A closure that takes an element as an argument and
1518-
/// returns a Boolean value indicating whether the sequence should be
1523+
/// returns a Boolean value indicating whether the collection should be
15191524
/// split at that element.
1520-
/// - Returns: An array of subsequences, split from this sequence's elements.
1525+
/// - Returns: An array of subsequences, split from this collection's
1526+
/// elements.
15211527
public func split(
15221528
maxSplits: Int = Int.max,
15231529
omittingEmptySubsequences: Bool = true,
15241530
isSeparator: @noescape (Iterator.Element) throws -> Bool
15251531
) rethrows -> [SubSequence] {
1532+
// TODO: swift-3-indexing-model - review the following
15261533
_precondition(maxSplits >= 0, "Must take zero or more splits")
15271534

15281535
var result: [SubSequence] = []
@@ -1564,64 +1571,67 @@ extension Collection {
15641571
}
15651572
}
15661573

1567-
// TODO: swift-3-indexing-model - review the following
15681574
extension Collection where Iterator.Element : Equatable {
1569-
/// Returns the longest possible subsequences of the sequence, in order, that
1570-
/// don't contain elements satisfying the given predicate. Elements that are
1571-
/// used to split the sequence are not returned as part of any subsequence.
1575+
/// Returns the longest possible subsequences of the collection, in order,
1576+
/// around elements equal to the given element.
1577+
///
1578+
/// The resulting array consists of at most `maxSplits + 1` subsequences.
1579+
/// Elements that are used to split the collection are not returned as part
1580+
/// of any subsequence.
15721581
///
15731582
/// The following examples show the effects of the `maxSplits` and
1574-
/// `omittingEmptySubsequences` parameters when splitting a string using a
1575-
/// closure that matches spaces. The first use of `split` returns each word
1576-
/// that was originally separated by one or more spaces.
1583+
/// `omittingEmptySubsequences` parameters when splitting a string at each
1584+
/// space character (" "). The first use of `split` returns each word that
1585+
/// was originally separated by one or more spaces.
15771586
///
15781587
/// let line = "BLANCHE: I don't want realism. I want magic!"
1579-
/// print(line.characters.split(isSeparator: { $0 == " " })
1588+
/// print(line.characters.split(separator: " ")
15801589
/// .map(String.init))
1581-
/// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
1590+
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
15821591
///
15831592
/// The second example passes `1` for the `maxSplits` parameter, so the
15841593
/// original string is split just once, into two new strings.
15851594
///
1586-
/// print(line.characters.split(maxSplits: 1, isSeparator: { $0 == " " })
1595+
/// print(line.characters.split(separator: " ", maxSplits: 1)
15871596
/// .map(String.init))
15881597
/// // Prints "["BLANCHE:", " I don\'t want realism. I want magic!"]"
15891598
///
15901599
/// The final example passes `false` for the `omittingEmptySubsequences`
15911600
/// parameter, so the returned array contains empty strings where spaces
15921601
/// were repeated.
15931602
///
1594-
/// print(line.characters.split(omittingEmptySubsequences: false, isSeparator: { $0 == " " })
1603+
/// print(line.characters.split(separator: " ", omittingEmptySubsequences: false)
15951604
/// .map(String.init))
15961605
/// // Prints "["BLANCHE:", "", "", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
15971606
///
15981607
/// - Parameters:
1599-
/// - maxSplits: The maximum number of times to split the sequence, or one
1600-
/// less than the number of subsequences to return. If `maxSplits + 1`
1601-
/// subsequences are returned, the last one is a suffix of the original
1602-
/// sequence containing the remaining elements. `maxSplits` must be
1603-
/// greater than or equal to zero.
1608+
/// - separator: The element that should be split upon.
1609+
/// - maxSplits: The maximum number of times to split the collection, or
1610+
/// one less than the number of subsequences to return. If
1611+
/// `maxSplits + 1` subsequences are returned, the last one is a suffix
1612+
/// of the original collection containing the remaining elements.
1613+
/// `maxSplits` must be greater than or equal to zero. The default value
1614+
/// is `Int.max`.
16041615
/// - omittingEmptySubsequences: If `false`, an empty subsequence is
1605-
/// returned in the result for each pair of consecutive elements
1606-
/// satisfying the `isSeparator` predicate and for each element at the
1607-
/// start or end of the sequence satisfying the `isSeparator` predicate.
1608-
/// - isSeparator: A closure that takes an element as an argument and
1609-
/// returns a Boolean value indicating whether the sequence should be
1610-
/// split at that element.
1611-
/// - Returns: An array of subsequences, split from this sequence's elements.
1616+
/// returned in the result for each consecutive pair of `separator`
1617+
/// elements in the collection and for each instance of `separator` at
1618+
/// the start or end of the collection. If `true`, only nonempty
1619+
/// subsequences are returned. The default value is `true`.
1620+
/// - Returns: An array of subsequences, split from this collection's
1621+
/// elements.
16121622
public func split(
16131623
separator: Iterator.Element,
16141624
maxSplits: Int = Int.max,
16151625
omittingEmptySubsequences: Bool = true
16161626
) -> [SubSequence] {
1617-
return split(
1618-
maxSplits: maxSplits,
1619-
omittingEmptySubsequences: omittingEmptySubsequences,
1620-
isSeparator: { $0 == separator })
1627+
// TODO: swift-3-indexing-model - review the following
1628+
return split(
1629+
maxSplits: maxSplits,
1630+
omittingEmptySubsequences: omittingEmptySubsequences,
1631+
isSeparator: { $0 == separator })
16211632
}
16221633
}
16231634

1624-
// TODO: swift-3-indexing-model - review the following
16251635
extension Collection where SubSequence == Self {
16261636
/// Removes and returns the first element of the collection.
16271637
///
@@ -1633,6 +1643,7 @@ extension Collection where SubSequence == Self {
16331643
/// - SeeAlso: `popFirst()`
16341644
@discardableResult
16351645
public mutating func removeFirst() -> Iterator.Element {
1646+
// TODO: swift-3-indexing-model - review the following
16361647
_precondition(!isEmpty, "can't remove items from an empty collection")
16371648
let element = first!
16381649
self = self[index(after: startIndex)..<endIndex]

stdlib/public/core/Sequence.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,11 @@ public protocol Sequence {
510510
func suffix(_ maxLength: Int) -> SubSequence
511511

512512
/// Returns the longest possible subsequences of the sequence, in order, that
513-
/// don't contain elements satisfying the given predicate. Elements that are
514-
/// used to split the sequence are not returned as part of any subsequence.
513+
/// don't contain elements satisfying the given predicate.
514+
///
515+
/// The resulting array consists of at most `maxSplits + 1` subsequences.
516+
/// Elements that are used to split the sequence are not returned as part of
517+
/// any subsequence.
515518
///
516519
/// The following examples show the effects of the `maxSplits` and
517520
/// `omittingEmptySubsequences` parameters when splitting a string using a
@@ -521,7 +524,7 @@ public protocol Sequence {
521524
/// let line = "BLANCHE: I don't want realism. I want magic!"
522525
/// print(line.characters.split(isSeparator: { $0 == " " })
523526
/// .map(String.init))
524-
/// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
527+
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
525528
///
526529
/// The second example passes `1` for the `maxSplits` parameter, so the
527530
/// original string is split just once, into two new strings.
@@ -822,7 +825,7 @@ extension Sequence {
822825
/// let line = "BLANCHE: I don't want realism. I want magic!"
823826
/// print(line.characters.split(isSeparator: { $0 == " " })
824827
/// .map(String.init))
825-
/// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
828+
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
826829
///
827830
/// The second example passes `1` for the `maxSplits` parameter, so the
828831
/// original string is split just once, into two new strings.
@@ -988,8 +991,11 @@ extension Sequence {
988991

989992
extension Sequence where Iterator.Element : Equatable {
990993
/// Returns the longest possible subsequences of the sequence, in order,
991-
/// around elements equal to the given element. Elements that are used to
992-
/// split the sequence are not returned as part of any subsequence.
994+
/// around elements equal to the given element.
995+
///
996+
/// The resulting array consists of at most `maxSplits + 1` subsequences.
997+
/// Elements that are used to split the sequence are not returned as part of
998+
/// any subsequence.
993999
///
9941000
/// The following examples show the effects of the `maxSplits` and
9951001
/// `omittingEmptySubsequences` parameters when splitting a string at each
@@ -999,7 +1005,7 @@ extension Sequence where Iterator.Element : Equatable {
9991005
/// let line = "BLANCHE: I don't want realism. I want magic!"
10001006
/// print(line.characters.split(separator: " ")
10011007
/// .map(String.init))
1002-
/// // Prints "["BLANCHE:", "I", "don't", "want", "realism.", "I", "want", "magic!"]"
1008+
/// // Prints "["BLANCHE:", "I", "don\'t", "want", "realism.", "I", "want", "magic!"]"
10031009
///
10041010
/// The second example passes `1` for the `maxSplits` parameter, so the
10051011
/// original string is split just once, into two new strings.

stdlib/public/core/UnsafePointer.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ public struct ${Self}<Pointee>
172172
///
173173
/// - Postcondition: The pointee is initialized; the value should eventually
174174
/// be destroyed or moved from to avoid leaks.
175-
// FIXME: add tests (since the `count` has been added)
176175
public func initialize(with newValue: Pointee, count: Int = 1) {
176+
// FIXME: add tests (since the `count` has been added)
177177
_debugPrecondition(count >= 0,
178178
"${Self}.initialize(with:): negative count")
179179
// Must not use `initializeFrom` with a `Collection` as that will introduce

0 commit comments

Comments
 (0)