In Alamofire, I find there is a enum:
public enum Result<Value, Error : ErrorType> {
case Success(Value)
case Failure(Error)
/// Returns `true` if the result is a success, `false` otherwise.
public var isSuccess: Bool { get }
/// Returns `true` if the result is a failure, `false` otherwise.
public var isFailure: Bool { get }
/// Returns the associated value if the result is a success, `nil` otherwise.
public var value: Value? { get }
/// Returns the associated error value if the result is a failure, `nil` otherwise.
public var error: Error? { get }
}
In struct Response, I will need to give its constructor a Result.
public init(request: NSURLRequest?, response: NSHTTPURLResponse?, data: NSData?, result: Alamofire.Result<Value, Error>)
But sadly, I find there is no init inside struct Response and every property only has a getter. So how could I init a Response and use it to init struct Response?