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
/// This module provides an asynchronous version of the rust's standard `Option` enum.
///
/// ```
/// # use tokio::runtime::Runtime;
/// use async_monad::async_traits::option::AsyncOption;
///
/// # let runtime = Runtime::new().unwrap();
/// # runtime.block_on(async {
/// async fn do_sth(val: u32) -> Option<u32> {
/// if val % 2 == 0 {
/// None
/// } else {
/// Some(val + 1)
/// }
/// }
/// assert_eq!(Some(5_u32).aand_then(do_sth).await, Some(6));
/// assert_eq!(Some(6_u32).aand_then(do_sth).await, None);
/// # });
/// ```
/// This module provides an asynchronous version of the rust's standard `Result` enum.
///
/// ```
/// # use tokio::runtime::Runtime;
/// use async_monad::async_traits::result::AsyncResult;
///
/// # let runtime = Runtime::new().unwrap();
/// # runtime.block_on(async {
/// async fn do_sth(val: u32) -> Result<u32, u32> {
/// if val % 2 == 0 {
/// Ok(val * 2)
/// } else {
/// Err(val + 1)
/// }
/// }
/// assert_eq!(Ok(5_u32).aand_then(do_sth).await, Err(6));
/// assert_eq!(Ok(6_u32).aand_then(do_sth).await, Ok(12));
/// # });
/// ```