Crates.io | klo-routines |
lib.rs | klo-routines |
version | 0.1.0 |
source | src |
created_at | 2021-07-15 17:34:06.733762 |
updated_at | 2021-07-15 17:34:06.733762 |
description | Rust cheap coroutines with libc::*context |
homepage | |
repository | https://github.com/andreafioraldi/klo-routines/ |
max_upload_size | |
id | 423168 |
size | 19,124 |
Rust cheap coroutines with libc::*context
use klo_routines::{flush, KloRoutine};
fn main() {
let mut cnt = 0;
let mut func = || {
for _ in 0..16 {
flush(cnt);
cnt += 1;
}
};
let mut klo = KloRoutine::new(&mut func);
while let Some(n) = klo.resume() {
println!("{}", n);
}
// or you can use it as iterator
// for n in &mut klo {
// println!("{}", n);
// }
}