stdlib: Mark many higher-order function interfaces as 'rethrows'.

This covers:

- Lifetime-extending wrappers, like withExtendedLifetime, withCString, and withUnsafe*Pointer
- 'map' and friends on Optional
- 'indexOf'

A few APIs I haven't gotten to yet in this first pass:

- Autoclosure APIs, like assert, &&, etc.
- the 'isOrderedBefore' predicate for sorting APIs. The sorting implementation does some microoptimizations with 'inout' closures that violate rethrows checking.
- Strict 'map', 'filter', and friends on CollectionType. These need some plumbing in Lazy to be able to thread a Result-forming transformation through.

This version of the patch updates some protocol customization implementations that I missed the first time around, and includes the tests I forgot to add in the previous iteration.

Swift SVN r30790
This commit is contained in:
Joe Groff
2015-07-30 05:28:17 +00:00
parent fe04ebfd2f
commit 1d49d927e1
17 changed files with 246 additions and 140 deletions

View File

@@ -57,10 +57,10 @@ extension CollectionType {
///
/// - Complexity: O(`self.count`).
public func indexOf(
@noescape predicate: (${GElement}) -> Bool
) -> Index? {
@noescape predicate: (${GElement}) throws -> Bool
) rethrows -> Index? {
for i in self.indices {
if predicate(self[i]) {
if try predicate(self[i]) {
return i
}
}