[stdlib] Conditional conformances for LazyMapCollection

(cherry picked from commit b927254564)
This commit is contained in:
Max Moiseev
2017-11-30 19:25:08 -08:00
parent ea02806f28
commit 1f78f3927b
5 changed files with 47 additions and 74 deletions

View File

@@ -95,8 +95,7 @@ extension LazyCollectionProtocol {
extension LazyCollectionProtocol
where
Self : BidirectionalCollection,
Elements : BidirectionalCollection
{
Elements : BidirectionalCollection {
/// Returns the concatenated results of mapping the given transformation over
/// this collection.
///
@@ -111,7 +110,7 @@ extension LazyCollectionProtocol
_ transform: @escaping (Elements.Element) -> SegmentOfResult
) -> LazyCollection<
FlattenBidirectionalCollection<
LazyMapBidirectionalCollection<Elements, SegmentOfResult>>> {
LazyMapCollection<Elements, SegmentOfResult>>> {
return self.map(transform).joined()
}
@@ -128,9 +127,9 @@ extension LazyCollectionProtocol
@_inlineable // FIXME(sil-serialize-all)
public func flatMap<ElementOfResult>(
_ transform: @escaping (Elements.Element) -> ElementOfResult?
) -> LazyMapBidirectionalCollection<
) -> LazyMapCollection<
LazyFilterCollection<
LazyMapBidirectionalCollection<Elements, ElementOfResult?>>,
LazyMapCollection<Elements, ElementOfResult?>>,
ElementOfResult
> {
return self.map(transform).filter { $0 != nil }.map { $0! }