-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Revert "Revert count(where:)" #70816
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
Conversation
This reverts commit 779ea19.
@swift-ci Please smoke test |
/// the element should be included in the count. | ||
/// - Returns: The number of elements in the sequence that satisfy the given | ||
/// predicate. | ||
@inlinable |
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.
Does this need availability? Could we make this @backDeploy
ed?
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 standard library can't effectively use @backDeploy
yet as there are, issues... I would however throw an @_alwaysEmitIntoClient
on.
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.
Should reduce
and/or typed throws
be used?
extension Sequence {
@_alwaysEmitIntoClient
public func count<Failure: Error>(
where predicate: (Element) throws(Failure) -> Bool
) throws(Failure) -> Int {
try reduce(into: 0) { result, element in
if try predicate(element) {
result += 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.
@benrimmington We're handling the addition of typed throws throughout the standard library separately. The loop is fine here.
@swift-ci Please smoke test |
@swift-ci Please smoke test Linux platform |
@swift-ci please smoke test |
This comment was marked as outdated.
This comment was marked as outdated.
@swift-ci Please smoke test |
@swift-ci Please test |
/// the element should be included in the count. | ||
/// - Returns: The number of elements in the sequence that satisfy the given | ||
/// predicate. | ||
@_alwaysEmitIntoClient |
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.
does this not need the ABI shims since it is AEIC?
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.
?
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.
This is brand-new API for the standard library, and it needs to be AEIC due to typed throws, so there's no existing ABI to worry about 👍🏻
This reverts commit 779ea19, to implement the re-acceptance of SE-0220.
https://github.com/apple/swift-evolution/blob/main/proposals/0220-count-where.md