New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stdlib] SR-361: Implement SE008: Add Lazy flatMap for Seq of Optionals #2461
Conversation
https://bugs.swift.org/browse/SR-361 Adds required LazyFilterRandomAccessCollection and the flatMap extensions.
@russbishop Thank you!
This wasn't a part of the proposal. This type was intentionally omitted because moving an index in a filtered collection can't be implemented in O(1) -- moving an index n steps requires evaluating the predicate n times. |
|
||
/// Returns a `LazyMapSequence` containing the concatenated non-nil | ||
/// results of mapping transform over this `Sequence`. The elements of | ||
/// the result are computed lazily, each time they are read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The summary of the doc comment should be a single sentence. CC @natecook1000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second sentence could just be removed, since that's covered by the Lazy...
type of the return.
@swift-ci Please test |
@gribozavr That makes sense now that I think about it. It seems like the overload for I'll also fixup the tests and pull in that dataset. |
@gribozavr I reverted the |
@russbishop Thank you! |
@swift-ci Please test |
/// - Parameter transform: A closure that accepts an element of this | ||
/// sequence as its argument and returns an optional value. | ||
@warn_unused_result | ||
public func flatMap<U>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change U
to ElementOfResult
?
If you feel like doing so, could you also change the names of generic type parameters in the eager flatMap
overloads (stdlib/public/core/SequenceAlgorithms.swift.gyb
) to SegmentOfResult
and ElementOfResult
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's no problem
@russbishop Thank you! The CI failures are unrelated. I just have two style comments, and we should be good to merge your PR. |
@gribozavr Pushed rename of generic arguments |
@swift-ci Please test and merge |
What's in this pull request?
LazyFilterRandomAccessCollection
to the generated boilerplateflatMap<U>(transform: (Element) -> U?)
extensions for sequences and the various kinds of collectionsResolved bug number: (SR-361)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
Validation Testing
Note: Only members of the Apple organization can trigger swift-ci.