streams-rs

Crates.iostreams-rs
lib.rsstreams-rs
version0.1.0
sourcesrc
created_at2020-05-22 10:50:31.635057
updated_at2020-05-22 10:50:31.635057
descriptionOCaml like streams for Russt
homepage
repositoryhttps://github.com/playXE/streams-rs
max_upload_size
id244530
size12,736
playX (playXE)

documentation

README

streams-rs

streams-rs provides OCaml like streams and macro to match on these streams.

Why?

Streams is really usefull when you have to read lines of files, parse something using lexer etc.

Example:

extern crate streams_rs;

use streams_rs::fn_stream::FnStream;
use streams_rs::*;
fn main() {
    let mut count = 0;
    let get = || {
        count += 1;
        StreamResult::Ok(count - 1)
    };
    let mut stream = FnStream::new(get);

    let _ = smatch!(match (stream) {
        [0=>] => {  // if not 0 then we do not match
            println!("Zero!");
        }
    });
    let _ = smatch!(match (stream) {
        [1=>] => { // if not 1 then we do not match
            println!("One!");
        }
    });
    for _ in 0..10 {
        let _ = smatch!(match (stream) {
            [a=>b=>] => { // get two values a and b from stream
                println!("a: {} b: {}",a,b);
            }
        });
    }
}
Commit count: 3

cargo fmt