Skip to content
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

Merged
merged 5 commits into from May 16, 2016

Conversation

russbishop
Copy link
Contributor

@russbishop russbishop commented May 14, 2016

What's in this pull request?

Implementation of SE-0032, adds first() to Sequence protocol along with default implementation.

I modified FindTest to give each of the elements a separate identity so the find 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:

  • Test pull request on Swift continuous integration.

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

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

@@ -950,13 +962,32 @@ extension Sequence {
///
/// - Parameter body: A closure that takes an element of the sequence as a
/// parameter.
@warn_unused_result
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@russbishop
Copy link
Contributor Author

@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 }
Copy link
Collaborator

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.

@russbishop
Copy link
Contributor Author

@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 {
Copy link
Collaborator

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.

@gribozavr
Copy link
Collaborator

@russbishop Thank you, LGTM modulo two style comments!

@russbishop
Copy link
Contributor Author

@gribozavr Done!

@gribozavr
Copy link
Collaborator

@swift-ci Please test and merge

@gribozavr
Copy link
Collaborator

@russbishop Could you take a look at the build errors?

@russbishop
Copy link
Contributor Author

@gribozavr Sorry about that, pushed a fix.

@gribozavr
Copy link
Collaborator

@swift-ci Please test and merge

@gribozavr
Copy link
Collaborator

CI failure is unrelated, merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants