提交 09fc146b 编写于 作者: C Christian Noon

Added CustomStringConvertible and CustomDebugStringConvertible conformance.

上级 1a12318d
......@@ -79,3 +79,36 @@ public enum Result<Value> {
}
}
}
// MARK: - CustomStringConvertible
extension Result: CustomStringConvertible {
public var description: String {
switch self {
case .Success:
return "SUCCESS"
case .Failure:
return "FAILURE"
}
}
}
// MARK: - CustomDebugStringConvertible
extension Result: CustomDebugStringConvertible {
public var debugDescription: String {
switch self {
case .Success(let value):
return "SUCCESS: \(value)"
case .Failure(let data, let error):
if let
data = data,
utf8Data = NSString(data: data, encoding: NSUTF8StringEncoding)
{
return "FAILURE: \(error) \(utf8Data)"
} else {
return "FAILURE with Error: \(error)"
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册