@@ -35,9 +35,9 @@ public final class SKDResponseArray {
35
35
36
36
/// If the `applier` returns `false`, iteration terminates.
37
37
@discardableResult
38
- public func forEach( _ applier: ( Int , SKDResponseDictionary ) -> Bool ) -> Bool {
38
+ public func forEach( _ applier: ( Int , SKDResponseDictionary ) throws -> Bool ) rethrows -> Bool {
39
39
for i in 0 ..< count {
40
- if !applier( i, SKDResponseDictionary ( sourcekitd. api. variant_array_get_value ( array, i) , response: resp) ) {
40
+ if try ! applier( i, SKDResponseDictionary ( sourcekitd. api. variant_array_get_value ( array, i) , response: resp) ) {
41
41
return false
42
42
}
43
43
}
@@ -46,29 +46,29 @@ public final class SKDResponseArray {
46
46
47
47
/// If the `applier` returns `false`, iteration terminates.
48
48
@discardableResult
49
- public func forEachUID( _ applier: ( Int , sourcekitd_uid_t ) -> Bool ) -> Bool {
49
+ public func forEachUID( _ applier: ( Int , sourcekitd_uid_t ) throws -> Bool ) rethrows -> Bool {
50
50
for i in 0 ..< count {
51
- if let uid = sourcekitd. api. variant_array_get_uid ( array, i) , !applier( i, uid) {
51
+ if let uid = sourcekitd. api. variant_array_get_uid ( array, i) , try ! applier( i, uid) {
52
52
return false
53
53
}
54
54
}
55
55
return true
56
56
}
57
57
58
- public func map< T> ( _ transform: ( SKDResponseDictionary ) -> T ) -> [ T ] {
58
+ public func map< T> ( _ transform: ( SKDResponseDictionary ) throws -> T ) rethrows -> [ T ] {
59
59
var result : [ T ] = [ ]
60
60
result. reserveCapacity ( self . count)
61
- self . forEach { _, element in
62
- result. append ( transform ( element) )
61
+ try self . forEach { _, element in
62
+ result. append ( try transform ( element) )
63
63
return true
64
64
}
65
65
return result
66
66
}
67
67
68
- public func compactMap< T> ( _ transform: ( SKDResponseDictionary ) -> T ? ) -> [ T ] {
68
+ public func compactMap< T> ( _ transform: ( SKDResponseDictionary ) throws -> T ? ) rethrows -> [ T ] {
69
69
var result : [ T ] = [ ]
70
- self . forEach { _, element in
71
- if let transformed = transform ( element) {
70
+ try self . forEach { _, element in
71
+ if let transformed = try transform ( element) {
72
72
result. append ( transformed)
73
73
}
74
74
return true
0 commit comments