#future #async-await #await #async

futures-either

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

Show the crate…

2 unstable releases

0.1.0 Sep 4, 2020
0.0.0 Aug 31, 2020

#99 in #await

Download history 2/week @ 2024-04-11 198/week @ 2024-04-18 152/week @ 2024-04-25 79/week @ 2024-05-02 74/week @ 2024-05-09 5/week @ 2024-05-16 14/week @ 2024-05-23 15/week @ 2024-05-30 89/week @ 2024-06-06 23/week @ 2024-06-13 48/week @ 2024-06-20 20/week @ 2024-06-27 89/week @ 2024-07-04 153/week @ 2024-07-11 125/week @ 2024-07-18 226/week @ 2024-07-25

599 downloads per month

MPL-2.0 license

14KB
135 lines

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/.


lib.rs:

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

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));
#

Dependencies

~56KB