klo-routines

Crates.ioklo-routines
lib.rsklo-routines
version0.1.0
sourcesrc
created_at2021-07-15 17:34:06.733762
updated_at2021-07-15 17:34:06.733762
descriptionRust cheap coroutines with libc::*context
homepage
repositoryhttps://github.com/andreafioraldi/klo-routines/
max_upload_size
id423168
size19,124
Andrea Fioraldi (andreafioraldi)

documentation

README

klo-routines

Rust cheap coroutines with libc::*context

Example

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);
    // }
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 6

cargo fmt