5 个版本
| 0.1.4 | 2020年5月28日 |
|---|---|
| 0.1.3 | 2019年11月24日 |
| 0.1.2 | 2019年11月22日 |
| 0.1.1 | 2019年11月15日 |
| 0.1.0 | 2019年11月15日 |
#17 in #either
21 每月下载量
用于 linked-futures
20KB
290 行
one-of-futures
概述
此包实现了几个自定义的具有 Future-aware 的 OneOf 类型,其行为类似于 Either 类型,但适用于超过两个变体。
它还公开了 impl_one_of! 宏,该宏允许生成具有所需数量和名称的变体的自定义 OneOf 类型。
功能
futures_03 启用对 futures 0.3 (core/std) 的支持,默认启用
sink 启用对 futures 0.3 (core/std) 的 Sink 的支持,默认启用
tokio-io 启用对 tokio 0.2 的 AsyncRead 和 AsyncWrite 的支持
futures_01 在 futures_01 模块下启用对 futures 0.1 的支持
用法
将其添加到您的 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 }),
};
}
依赖项
~0–0.8MB
~12K SLoC