Remit
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.
Usage
Add to dependencies:
[]
= "0.1.1"
Example code:
use pin;
use ;
async
for item in pin!.of.take
assert_eq!;
/* // Rust has trouble determining the lifetime
assert_eq!(
vec![1],
pin!(Generator::new())
.of(|remit: Remit<'_, usize>| async move { remit.value(1).await; })
.collect::<Vec<_>>(),
);
*/
assert_eq!;
assert_eq!;
async
let expected: = .iter.map.collect;
assert_eq!;
assert_eq!;
License
MIT or APACHE-2, at your option.
See respective LICENSE files.