Rust generators implemented through async/await syntax.
The pinned implementation is stack-based, and the boxed is heap-based. No fancy macros and a simple API. Values can be lazily or eagerly yielded.
This crate is inherently no-std, and the default alloc
feature can be disabled.
Some behaviors exhibited by the lack of alloc
are not part of the SemVer.
For example, not awaiting before another remit, without alloc, is
unspecified
behavior.
Add to dependencies:
toml
[dependencies]
remit = "0.1.1"
Example code: ```rust use std::pin::pin; use remit::{Generator, Remit};
async fn gen(remit: Remit<', usize>) {
remit.value(42).await;
// Does not need to be limited
for i in 1.. {
remit.value(i).await
}
}
for item in pin!(Generator::new()).of(gen).take(10) {
println!("{item}");
// Prints 42, 1, 2, 3, 4, 5, 6, 7, 8, 9
}
asserteq!(vec![42, 1, 2, 3], pin!(Generator::new()).of(gen).take(4).collect::
fn iter() -> impl Iterator
async fn scream
MIT or APACHE-2, at your option.
See respective LICENSE files.