Skip to content

Commit b4370c9

Browse files
committed
Clean up documentation; explain use of try!
1 parent 7677893 commit b4370c9

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Sources/Algorithms/SortedDuplicates.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ extension Sequence {
1818
/// - Precondition: This sequence must be finite,
1919
/// and be sorted according to the given predicate.
2020
///
21-
/// - Parameters:
22-
/// - type: A reference to the returned collection's type.
23-
/// - areInIncreasingOrder: The sorting predicate.
21+
/// - Parameter type: A reference to the returned collection's type.
22+
/// - Parameter areInIncreasingOrder: The sorting predicate.
2423
/// - Returns: A collection of pairs,
2524
/// one for each element equivalence class present in this sequence,
2625
/// in order of appearance.
@@ -56,8 +55,7 @@ extension Sequence {
5655
/// - Precondition: This sequence must be finite,
5756
/// and be sorted according to the given predicate.
5857
///
59-
/// - Parameters:
60-
/// - areInIncreasingOrder: The sorting predicate.
58+
/// - Parameter areInIncreasingOrder: The sorting predicate.
6159
/// - Returns: An array of pairs,
6260
/// one for each element equivalence class present in this sequence,
6361
/// in order of appearance.
@@ -80,8 +78,7 @@ extension Sequence {
8078
/// - Precondition: This sequence must be finite,
8179
/// and be sorted according to the given predicate.
8280
///
83-
/// - Parameters:
84-
/// - areInIncreasingOrder: The sorting predicate.
81+
/// - Parameter areInIncreasingOrder: The sorting predicate.
8582
///
8683
/// - Returns: An array with the earliest element in this sequence for
8784
/// each equivalence class.
@@ -137,8 +134,7 @@ extension LazySequenceProtocol {
137134
/// - Precondition: This squence is sorted according to the given predicate,
138135
/// and cannot end with an infinite run of a single equivalence class.
139136
///
140-
/// - Parameters:
141-
/// - areInIncreasingOrder: The sorting predicate.
137+
/// - Parameter areInIncreasingOrder: The sorting predicate.
142138
///
143139
/// - Returns: A sequence that lazily generates the first element of
144140
/// each equivalence class present in this sequence paired with
@@ -156,8 +152,7 @@ extension LazySequenceProtocol {
156152
/// - Precondition: This squence is sorted according to the given predicate,
157153
/// and cannot end with an infinite run of a single equivalence class.
158154
///
159-
/// - Parameters:
160-
/// - areInIncreasingOrder: The sorting predicate.
155+
/// - Parameter areInIncreasingOrder: The sorting predicate.
161156
///
162157
/// - Returns: A sequence that lazily generates the first element of
163158
/// each equivalence class present in this sequence.
@@ -260,6 +255,8 @@ public struct CountDuplicatesIterator<Base: IteratorProtocol> {
260255

261256
extension CountDuplicatesIterator: IteratorProtocol {
262257
public mutating func next() -> (value: Base.Element, count: Int)? {
258+
// NOTE: This method is called only when the predicate isn't `throw`-ing,
259+
// so the forced `try` is OK.
263260
try! throwingNext()
264261
}
265262

0 commit comments

Comments
 (0)