Mirai provides Rust-styled Future

Mirai

Mirai provides Rust-styled Future like stuff.

Installation

Please use the Swift Package Manager.

dependencies: [
    .package(url: "https://github.com/moriturus/Mirai.git", .upToNextMajor(from: "1.0.0"))
]

Usage

let future = Future<Int>(just: 0)

do {
    let value = try await future.get()
} catch {
    // handle errors
}

or

func provideSomeValue() async -> Int {
    0
}

let futureByAsyncFunction = Future(provider: provideSomeValue)

do {
    let value = try await futureByAsyncFunction.get()
} catch {
    // handle errors.
}

License

This software is released under the MIT License. See LICENSE file for details.

GitHub

View Github