Crates.io | one-of-futures |
lib.rs | one-of-futures |
version | 0.1.4 |
source | src |
created_at | 2019-11-15 16:35:12.245949 |
updated_at | 2020-05-28 09:09:32.469018 |
description | Future-aware Either-like type with multiple variants |
homepage | https://github.com/glebpom/one-of-futures |
repository | https://github.com/glebpom/one-of-futures |
max_upload_size | |
id | 181542 |
size | 21,356 |
This crate implements several custom future-aware OneOf
types, which behaves
similarly to Either
type,
but suitable for more than two variants.
It also exposes impl_one_of!
macro, which allows generating custom OneOf
type,
with the desired number and names of variants
futures_03
enables support for futures 0.3 (core/std), enabled by default
sink
enables support for futures 0.3 (core/std)'s Sink
, enabled by default
tokio-io
enabled support for tokio 0.2's AsyncRead
and AsyncWrite
futures_01
enables support for futures 0.1 under the futures_01 module
Add this to your Cargo.toml
:
[dependencies]
one-of-futures = "0.1"
use one_of_futures::impl_one_of;
impl_one_of!(MyEither;
Left,
Right
);
fn main() {
let either = match 1 {
0 => MyEither::Left(async { 1 }),
_ => MyEither::Right(async { 2 }),
};
}