r3v2d0g / futures-either

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A way to await on the output of either of two futures

img img img

Example

use futures_lite::future;
use futures_either::{either, Either};

let out = either(
    async { 42 },
    async { false },
).await;
assert_eq!(out, Either::Left(42));

let out = either(
    future::pending::<bool>(),
    async { 42 },
).await;
assert_eq!(out, Either::Right(42));

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

About

License:Mozilla Public License 2.0


Languages

Language:Rust 100.0%