FutureProtocol
public protocol FutureProtocol
All Futures use the protocol FutureProtocol
-
convert this future of type
Future<T>
into another future typeFuture<S>
may fail to compile if T is not convertable into S using
`as!`
works iff the following code works:
let t : T let s = t as! S
example:
let f = Future<Int>(success:5) let f2 : Future<Int32> = f.As() assert(f2.result! == Int32(5))
you will need to formally declare the type of the new variable (ex:
f2
), in order for Swift to perform the correct conversion.the following conversions should always work for any future
let fofany : Future<Any> = f.As() let fofvoid: Future<Void> = f.As()
Declaration
Swift
func mapAs<S>() -> Future<S>
-
convert Future
into another type Future .WARNING: if ’T as! S’ isn’t legal, than all Success values may be converted to nil
example: let f = Future
(success: 5
) let f2 : Future<[Int]?> = f.convertOptional() assert(f2.result! == nil)you will need to formally declare the type of the new variable (ex:
f2
), in order for Swift to perform the correct conversion.Declaration
Swift
func mapAsOptional<S>() -> Future<S?>
-
Undocumented
Declaration
Swift
public protocol FutureProtocol