Skip to content

Latest commit

 

History

History
32 lines (28 loc) · 1.07 KB

README.md

File metadata and controls

32 lines (28 loc) · 1.07 KB

Lang mit SwiftLint Sindre Tests

ResultSugar

Sugar for Result

Install:

  • SPM: .url("https://github.com/eonist/ResultSugar.git"), .branch("master")
  • Manual Open .xcodeproj

Example:

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 🚫")))
  }
}

Todo:

  • Make more succinct example
  • Make more examples
  • Make more Unit-tests