channel_pipes

Crates.iochannel_pipes
lib.rschannel_pipes
version0.2.0
sourcesrc
created_at2022-02-07 19:10:49.495532
updated_at2022-02-10 03:35:33.643391
descriptionPerform operations on broadcast queues.
homepage
repositoryhttps://github.com/Frixuu/ChannelPipes
max_upload_size
id528556
size13,194
(Frixuu)

documentation

README

channel_pipes

Crates.io Crates.io Crates.io
GitHub last commit Lines of code

Usage

If you use crossbeam-channel, add this to your Cargo.toml:

[dependencies]
channel_pipes = { version = "0.2", features = ["crossbeam"] }

Examples

use channel_pipes::{operators::DistinctUntilChanged, CrossbeamSender, IntoPiped};
use crossbeam_channel::unbounded;

fn main() {
    let (s, r) = unbounded::<i32>().pipe().distinct_until_changed();

    let vec = vec![1, 2, 2, 3, 3, 3, 1];
    for i in vec {
        s.send(i);
    }

    assert_eq!(Ok(1), r.try_recv());
    assert_eq!(Ok(2), r.try_recv());
    assert_eq!(Ok(3), r.try_recv());
    assert_eq!(Ok(1), r.try_recv());
    assert!(r.try_recv().is_err());
}
Commit count: 16

cargo fmt