Crates.io | tokio-stream-extra |
lib.rs | tokio-stream-extra |
version | 0.0.3 |
source | src |
created_at | 2022-12-08 17:03:24.738297 |
updated_at | 2022-12-09 08:50:25.559876 |
description | A crate for stream extensions. |
homepage | |
repository | https://github.com/veminovici/tokio-stream-extra |
max_upload_size | |
id | 732701 |
size | 16,819 |
A crate that extends the Stream trait. For more details about streams please check the tokio-stream crate as well as StreamExt trait documentation.
Splits this stream's items at a separation item. The separation item
is determined by provided closure. A stream of vectors of item type will be returned,
which will yield elements until the closure returns None
.
[tokio::main]
async fn main() {
use tokio_stream::{self as stream, StreamExt};
use tokio_stream_extra::StreamExtra;
let stream = stream::iter(vec![1,2,0,3,4,0]);
let mut stream = stream.split(|x| x == &0);
assert_eq!(stream.next().await, Some(vec![1,2]));
assert_eq!(stream.next().await, Some(vec![3,4]));
To get the test coverage, I use the grcov. See the instructions steps.
export RUSTFLAGS="-Cinstrument-coverage"
export LLVM_PROFILE_FILE="./coverage/lib-%p-%m.profraw"
cargo build
cargo test
grcov ./coverage -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
open ./target/debug/coverage/index.html
The library is using property based testing. It uses the quickcheck crate.
Code designed and written on the beautiful island of Saaremaa, Estonia.