clone-stream 0.4.1

Turn any Stream into a cloneable stream where each clone receives all items independently.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use clone_stream::ForkStream;
use futures::stream;

/// Test that clone count limit is enforced by panicking
#[tokio::test]
#[should_panic(expected = "Failed to register clone - clone limit exceeded")]
async fn test_clone_count_limit_error() {
    let values = vec![1, 2, 3];
    let stream = stream::iter(values);

    let original = stream.fork_with_limits(1000, 2); // Very small clone limit

    let _clone1 = original.clone();
    let _clone2 = original.clone();
    #[allow(clippy::redundant_clone)]
    let _clone3 = original.clone(); // This will panic
}