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
55
56
57
// #![include_doc("../README.md", start)]
//! # yield-return-rs
//!
//! [](https://crates.io/crates/yield-return)
//! [](https://docs.rs/yield-return/)
//! [](https://github.com/frozenlib/yield-return-rs/actions)
//!
//! Implement a coroutine like C#'s `yield return` using Rust's `async`, `await`.
//!
//! ## Example
//!
//! ```rust
//! use yield_return::Iter;
//! let iter = Iter::new(|mut y| async move {
//! y.ret(1).await;
//! y.ret(2).await;
//! });
//! let list: Vec<_> = iter.collect();
//! assert_eq!(list, vec![1, 2]);
//! ```
//!
//! ## Available Types
//!
//! This crate provides several iterator types that differ based on two characteristics:
//!
//! - Whether they implement `Iterator` or `Stream`
//! - Whether they require and implement `Send`
//!
//! The following table shows the available types:
//!
//! | | `Send` | Not `Send` |
//! | ------------ | ----------- | ---------------- |
//! | [`Iterator`] | `Iter` | `LocalIter` |
//! | [`Stream`] | `AsyncIter` | `LocalAsyncIter` |
//!
//! [`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html
//! [`Stream`]: https://docs.rs/futures/latest/futures/stream/trait.Stream.html
//!
//! ## Compare with other crates
//!
//! While [async-stream] and [genawaiter] serve similar purposes, [yield-return] focuses on usability over performance. This design philosophy is reflected in two key characteristics:
//!
//! - Type parameters only expose the external interface, not implementation details
//! - Clean API using only types and functions (no macros)
//!
//! [async-stream]: https://crates.io/crates/async-stream
//! [genawaiter]: https://crates.io/crates/genawaiter
//! [yield-return]: https://crates.io/crates/yield-return
//!
//! ## License
//!
//! This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-\* files for details.
//!
//! ## Contribution
//!
//! Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
// #![include_doc("../README.md", end)]