async_iterator/
lib.rs

1//! An async version of iterator.
2//!
3//! This crate provides the following capabilities:
4//!
5//! - The base async `Iterator` trait implemented with `async fn next`
6//! - The ability to `collect` into a `vec`
7//! - The ability to asynchronously `map` over values in the iterator
8//! - The ability to extend `vec` with an async iterator
9//!
10//! # Minimum Supported Rust Version
11//!
12//! This code should be considered _unstable_ and only works on recent versions
13//! of nightly.
14//!
15//! # Trait definitions
16//!
17//! All traits make use of the `async_trait` annotation. In order to implement
18//! the traits, use `async_trait`.
19//!
20#![cfg_attr(not(feature = "std"), no_std)]
21#![allow(async_fn_in_trait)]
22#![forbid(unsafe_code, future_incompatible)]
23#![deny(missing_debug_implementations, nonstandard_style)]
24#![warn(missing_docs)]
25
26mod extend;
27mod from_iterator;
28mod into_iterator;
29mod iter;
30mod lending_iter;
31
32pub use from_iterator::FromIterator;
33pub use into_iterator::IntoIterator;
34pub use lending_iter::LendingIterator;
35
36pub use iter::{Iterator, Lend, LendMut, Map};
37
38/// The `async-iterator` prelude
39pub mod prelude {
40    pub use crate::extend::Extend;
41    pub use crate::from_iterator::FromIterator;
42    pub use crate::into_iterator::IntoIterator;
43}
44
45#[cfg(feature = "alloc")]
46extern crate alloc as std;
47
48#[cfg(all(test, feature = "alloc"))]
49mod test {
50    pub use super::*;
51
52    #[test]
53    fn smoke() {
54        #[allow(dead_code)]
55        async fn foo(iter: impl Iterator<Item = u32>) {
56            let _v: Vec<_> = iter.collect().await;
57        }
58    }
59}