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-1519: Implement SE-0032: Add Sequence.first(predicate:) #2529
Conversation
@@ -950,13 +962,32 @@ extension Sequence { | |||
/// | |||
/// - Parameter body: A closure that takes an element of the sequence as a | |||
/// parameter. | |||
@warn_unused_result |
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.
Looks like an unrelated edit... Even more, @warn_unused_result
does nothing now.
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.
Sorry, my fault. I also didn't realize @discardable_result
landed already.
@gribozavr Pushed the other changes, all tests pass locally. Just waiting to get your opinion on the throw to stop iteration code. |
|
||
SequenceTypeTests.test("first/dispatch") { | ||
let tester = SequenceLog.dispatchTester([OpaqueValue(1)]) | ||
tester.first { return $0.value == 1 } |
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.
return
is probably not needed here.
@gribozavr I think this is ready to go unless you can think of anything else |
@@ -959,6 +970,34 @@ extension Sequence { | |||
} | |||
} | |||
|
|||
private enum _StopIteration: ErrorProtocol { |
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.
Sorry, one more thing -- we can't use private
in the library due to a compiler bug. Please use internal
.
Please add a space before the colon to conform to the library coding style.
@russbishop Thank you, LGTM modulo two style comments! |
@gribozavr Done! |
@swift-ci Please test and merge |
@russbishop Could you take a look at the build errors? |
@gribozavr Sorry about that, pushed a fix. |
@swift-ci Please test and merge |
CI failure is unrelated, merging. |
What's in this pull request?
Implementation of SE-0032, adds
first()
toSequence
protocol along with default implementation.I modified
FindTest
to give each of the elements a separateidentity
so thefind
test can verify it found the first element and not just any matching element.Resolved bug number: (SR-1519)
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.