-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
Description
Previous ID | SR-13816 |
Radar | rdar://problem/70998651 |
Original Reporter | laclouis5 (JIRA User) |
Type | Improvement |
Additional Detail from JIRA
Votes | 0 |
Component/s | Standard Library |
Labels | Improvement |
Assignee | None |
Priority | Medium |
md5: 428272cf422670a09b2e579ae777d8bf
Issue Description:
Currently FlattenSequence does not conditionally conform to LazySequenceProtocol when its base does, however, this behavior is supported through this implementation in the standard library:
extension LazySequenceProtocol where Element: Sequence {
/// Returns a lazy sequence that concatenates the elements of this sequence of
/// sequences.
@inlinable // lazy-performance
public __consuming func joined() -> LazySequence<FlattenSequence<Elements>> {
return FlattenSequence(_base: elements).lazy
}
}
This is an uncommon and convoluted way to add lazy behavior to FlattenSequence (when base does), the classic approach in the standard library is the following one:
extension Slice: LazySequenceProtocol where Base: LazySequenceProtocol { }
extension ReversedCollection: LazySequenceProtocol where Base: LazySequenceProtocol { }
This minor issue may feel awkward because the returning type of someSequenceOfSequence.lazy.joined()
is not FlattenSequence<LazySequence<...>>
as expected but LazySequence<FlattenSequence<...>>
.
Fixing this would reduce the number of overloads of the joined()
method to 1 and make the standard library more consistent.