async_hofs/
lib.rs

1#![cfg_attr(not(test), no_std)]
2
3//! Various extention traits for providing asynchronous higher-order functions.
4//!
5//! # Examples
6//!
7//! ```
8//! # #[tokio::main]
9//! # async fn main() {
10//! // This won't make any name conflicts since all imports inside prelude are anonymous.
11//! use async_hofs::prelude::*;
12//!
13//! assert_eq!(
14//!     Some(1).async_map(|x| async move { x + 2 }).await,
15//!     Some(3),
16//! );
17//!
18//! type Result = core::result::Result<i32, i32>;
19//!
20//! assert_eq!(
21//!     Result::Ok(1).async_and_then(|_| async move { Err(77) }).await,
22//!     Result::Err(77)
23//! );
24//! # }
25//! ```
26
27mod async_util;
28pub mod iter;
29pub mod option;
30pub mod result;
31pub mod stream;
32
33pub mod prelude {
34    pub use crate::iter::AsyncMapExt as _;
35    pub use crate::option::AsyncMapExt as _;
36    pub use crate::result::AsyncMapExt as _;
37    pub use crate::stream::AsyncMapExt as _;
38}