Sugar for Result
- SPM:
.url("https://github.com/eonist/ResultSugar.git"), .branch("master")
- Manual Open
.xcodeproj
typealias OnComplete = (Result<String, Error>) -> Void
ResultSugarTests.assert(flag: true) { result in
guard let msg: String = result.value() else { Swift.print("\(result.errorStr)"); return }
Swift.print("\(msg)") // Works 👌
}
static func assert(flag: Bool, complete: OnComplete) {
if flag {
complete(.success("Works 👌"))
} else {
complete(.failure(NSError("Doesn't work 🚫")))
}
}
- Make more succinct example
- Make more examples
- Make more Unit-tests