| Crates.io | yield-return |
| lib.rs | yield-return |
| version | 0.2.0 |
| created_at | 2023-04-21 01:21:14.736998+00 |
| updated_at | 2025-01-10 10:47:31.74608+00 |
| description | Implement a coroutine like C#'s `yield return` using Rust's `async`, `await`. |
| homepage | |
| repository | https://github.com/frozenlib/yield-return-rs |
| max_upload_size | |
| id | 844901 |
| size | 54,764 |
Implement a coroutine like C#'s yield return using Rust's async, await.
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]);
This crate provides several iterator types that differ based on two characteristics:
Iterator or StreamSendThe following table shows the available types:
Send |
Not Send |
|
|---|---|---|
Iterator |
Iter |
LocalIter |
Stream |
AsyncIter |
LocalAsyncIter |
While async-stream and genawaiter serve similar purposes, yield-return focuses on usability over performance. This design philosophy is reflected in two key characteristics:
This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.
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.