@@ -187,6 +187,7 @@ extension Optional {
187
187
/// returns `nil`.
188
188
@inlinable
189
189
public func map< U> (
190
+ // FIXME: This needs to support typed throws.
190
191
_ transform: ( Wrapped ) throws -> U
191
192
) rethrows -> U ? {
192
193
switch self {
@@ -200,22 +201,22 @@ extension Optional {
200
201
201
202
extension Optional where Wrapped: ~ Copyable {
202
203
@_alwaysEmitIntoClient
203
- public consuming func consumingMap< U : ~ Copyable> (
204
- _ transform: ( consuming Wrapped ) throws -> U
205
- ) rethrows -> U ? {
206
- switch /* consume*/ self {
204
+ public consuming func consumingMap< U : ~ Copyable, E : Error > (
205
+ _ transform: ( consuming Wrapped ) throws ( E ) -> U
206
+ ) throws ( E ) -> U ? {
207
+ switch consume self {
207
208
case . some( let y ) :
208
- return . some( try transform ( consume y) )
209
+ return . some ( try transform( y ) )
209
210
case . none :
210
211
return . none
211
212
}
212
213
}
213
214
214
215
#if $BorrowingSwitch
215
216
@_alwaysEmitIntoClient
216
- public borrowing func borrowingMap< U: ~ Copyable> (
217
- _ transform: ( borrowing Wrapped ) throws -> U
218
- ) rethrows -> U ? {
217
+ public borrowing func borrowingMap< U: ~ Copyable, E : Error > (
218
+ _ transform: ( borrowing Wrapped ) throws ( E ) -> U
219
+ ) throws ( E ) -> U ? {
219
220
switch self {
220
221
case . some( _borrowing y) :
221
222
return . some( try transform ( y) )
@@ -248,6 +249,7 @@ extension Optional {
248
249
/// returns `nil`.
249
250
@inlinable
250
251
public func flatMap< U> (
252
+ // FIXME: This needs to support typed throws.
251
253
_ transform: ( Wrapped ) throws -> U ?
252
254
) rethrows -> U ? {
253
255
switch self {
@@ -261,10 +263,9 @@ extension Optional {
261
263
262
264
extension Optional where Wrapped: ~ Copyable {
263
265
@_alwaysEmitIntoClient
264
- @inlinable
265
- public consuming func consumingFlatMap< U : ~ Copyable> (
266
- _ transform: ( consuming Wrapped ) throws -> U ?
267
- ) rethrows -> U ? {
266
+ public consuming func consumingFlatMap< U : ~ Copyable, E : Error> (
267
+ _ transform: ( consuming Wrapped ) throws ( E ) -> U ?
268
+ ) throws ( E ) -> U ? {
268
269
switch consume self {
269
270
case . some( let y ) :
270
271
return try transform( consume y)
@@ -275,10 +276,9 @@ extension Optional where Wrapped: ~Copyable {
275
276
276
277
#if $BorrowingSwitch
277
278
@_alwaysEmitIntoClient
278
- @inlinable
279
- public func borrowingFlatMap< U: ~ Copyable> (
280
- _ transform: ( borrowing Wrapped ) throws -> U ?
281
- ) rethrows -> U ? {
279
+ public func borrowingFlatMap< U: ~ Copyable, E: Error > (
280
+ _ transform: ( borrowing Wrapped ) throws ( E ) -> U ?
281
+ ) throws ( E) -> U ? {
282
282
switch self {
283
283
case . some( _borrowing y) :
284
284
return try transform ( y)
0 commit comments