1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! [![Documentation](https://docs.rs/async-fuse/badge.svg)](https://docs.rs/async-fuse)
//! [![Crates](https://img.shields.io/crates/v/async-fuse.svg)](https://crates.io/crates/async-fuse)
//! [![Actions Status](https://github.com/udoprog/async-fuse/workflows/Rust/badge.svg)](https://github.com/udoprog/async-fuse/actions)
//!
//! Helpers for fusing asynchronous computations.
//!
//! This is especially useful in combination with optional branches using
//! [tokio::select], where the future being polled isn't necessarily set. So
//! instead of requiring a potentially problematic [branch precondition], the
//! future will simply be marked as pending indefinitely.
//!
//! # Features
//!
//! * `stream` - Makes `Heap` and `Stack` implement the [`Stream` trait] if
//!   they contain a stream.
//!
//! # Examples
//!
//! > This is available as the `ticker` example:
//! > ```sh
//! > cargo run --example ticker
//! > ```
//!
//! ```rust
//! use std::time::Duration;
//! use tokio::time;
//!
//! # #[tokio::main]
//! # async fn main() {
//! let sleep = async_fuse::Stack::new(time::sleep(Duration::from_millis(100)));
//! tokio::pin!(sleep);
//!
//! for _ in 0..20usize {
//!     (&mut sleep).await;
//!     assert!(sleep.is_empty());
//!
//!     println!("tick");
//!
//!     sleep.set(async_fuse::Stack::new(time::sleep(Duration::from_millis(100))))
//! }
//! # }
//! ```
//!
//! [`Stream` trait]: https://docs.rs/futures-core/0/futures_core/stream/trait.Stream.html
//! [branch precondition]: https://docs.rs/tokio/1.0.1/tokio/macro.select.html#avoid-racy-if-preconditions
//! [tokio::select]: https://docs.rs/tokio/1/tokio/macro.select.html

#![deny(missing_docs)]

mod heap;
mod stack;

pub use self::heap::Heap;
pub use self::stack::Stack;