Skip to content

Commit 7dc71d0

Browse files
author
Russ Bishop
committed
Rename generic arguments
1 parent 9af775b commit 7dc71d0

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

stdlib/public/core/FlatMap.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ extension LazySequenceProtocol {
3434
/// - Parameter transform: A closure that accepts an element of this
3535
/// sequence as its argument and returns an optional value.
3636
@warn_unused_result
37-
public func flatMap<U>(
38-
_ transform: (Self.Elements.Iterator.Element) -> U?
37+
public func flatMap<ElementOfResult>(
38+
_ transform: (Elements.Iterator.Element) -> ElementOfResult?
3939
) -> LazyMapSequence<
4040
LazyFilterSequence<
41-
LazyMapSequence<Self.Elements, U?>>,
42-
U
41+
LazyMapSequence<Elements, ElementOfResult?>>,
42+
ElementOfResult
4343
> {
4444
return self.map(transform).filter { $0 != nil }.map { $0! }
4545
}
@@ -71,12 +71,12 @@ extension LazyCollectionProtocol {
7171
/// - Parameter transform: A closure that accepts an element of this
7272
/// collection as its argument and returns an optional value.
7373
@warn_unused_result
74-
public func flatMap<U>(
75-
_ transform: (Self.Elements.Iterator.Element) -> U?
74+
public func flatMap<ElementOfResult>(
75+
_ transform: (Elements.Iterator.Element) -> ElementOfResult?
7676
) -> LazyMapCollection<
7777
LazyFilterCollection<
78-
LazyMapCollection<Self.Elements, U?>>,
79-
U
78+
LazyMapCollection<Elements, ElementOfResult?>>,
79+
ElementOfResult
8080
> {
8181
return self.map(transform).filter { $0 != nil }.map { $0! }
8282
}
@@ -114,12 +114,12 @@ extension LazyCollectionProtocol
114114
///
115115
/// - Parameter transform: A closure that accepts an element of this
116116
/// collection as its argument and returns an optional value.
117-
public func flatMap<U>(
118-
_ transform: (Self.Elements.Iterator.Element) -> U?
117+
public func flatMap<ElementOfResult>(
118+
_ transform: (Elements.Iterator.Element) -> ElementOfResult?
119119
) -> LazyMapBidirectionalCollection<
120120
LazyFilterBidirectionalCollection<
121-
LazyMapBidirectionalCollection<Self.Elements, U?>>,
122-
U
121+
LazyMapBidirectionalCollection<Elements, ElementOfResult?>>,
122+
ElementOfResult
123123
> {
124124
return self.map(transform).filter { $0 != nil }.map { $0! }
125125
}

stdlib/public/core/SequenceAlgorithms.swift.gyb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,10 @@ extension Sequence {
657657
/// - Complexity: O(*m* + *n*), where *m* is the length of this sequence
658658
/// and *n* is the length of the result.
659659
@warn_unused_result
660-
public func flatMap<T>(
661-
_ transform: @noescape (${GElement}) throws -> T?
662-
) rethrows -> [T] {
663-
var result: [T] = []
660+
public func flatMap<ElementOfResult>(
661+
_ transform: @noescape (${GElement}) throws -> ElementOfResult?
662+
) rethrows -> [ElementOfResult] {
663+
var result: [ElementOfResult] = []
664664
for element in self {
665665
if let newElement = try transform(element) {
666666
result.append(newElement)

0 commit comments

Comments
 (0)