Sha256: 50fba3495bdf4e91a84ad105b148b6cd72f73f64a85703414eeb2d07732c66b9

Contents?: true

Size: 1.26 KB

Versions: 25

Compression:

Stored size: 1.26 KB

Contents

use futures::channel::mpsc;
use futures::stream::Stream;

#[test]
fn unbounded_size_hint() {
    let (tx, mut rx) = mpsc::unbounded::<u32>();
    assert_eq!((0, None), rx.size_hint());
    tx.unbounded_send(1).unwrap();
    assert_eq!((1, None), rx.size_hint());
    rx.try_next().unwrap().unwrap();
    assert_eq!((0, None), rx.size_hint());
    tx.unbounded_send(2).unwrap();
    tx.unbounded_send(3).unwrap();
    assert_eq!((2, None), rx.size_hint());
    drop(tx);
    assert_eq!((2, Some(2)), rx.size_hint());
    rx.try_next().unwrap().unwrap();
    assert_eq!((1, Some(1)), rx.size_hint());
    rx.try_next().unwrap().unwrap();
    assert_eq!((0, Some(0)), rx.size_hint());
}

#[test]
fn channel_size_hint() {
    let (mut tx, mut rx) = mpsc::channel::<u32>(10);
    assert_eq!((0, None), rx.size_hint());
    tx.try_send(1).unwrap();
    assert_eq!((1, None), rx.size_hint());
    rx.try_next().unwrap().unwrap();
    assert_eq!((0, None), rx.size_hint());
    tx.try_send(2).unwrap();
    tx.try_send(3).unwrap();
    assert_eq!((2, None), rx.size_hint());
    drop(tx);
    assert_eq!((2, Some(2)), rx.size_hint());
    rx.try_next().unwrap().unwrap();
    assert_eq!((1, Some(1)), rx.size_hint());
    rx.try_next().unwrap().unwrap();
    assert_eq!((0, Some(0)), rx.size_hint());
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
wasmtime-28.0.0 ./ext/cargo-vendor/futures-channel-0.3.31/tests/mpsc-size_hint.rs
wasmtime-27.0.0 ./ext/cargo-vendor/futures-channel-0.3.31/tests/mpsc-size_hint.rs
wasmtime-26.0.0 ./ext/cargo-vendor/futures-channel-0.3.31/tests/mpsc-size_hint.rs
wasmtime-25.0.2 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-25.0.1 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-25.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-24.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-23.0.2 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-22.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-21.0.1 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-20.0.2 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-20.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-18.0.3 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-17.0.1 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-17.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-16.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-15.0.1 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-15.0.0 ./ext/cargo-vendor/futures-channel-0.3.30/tests/mpsc-size_hint.rs
wasmtime-14.0.4 ./ext/cargo-vendor/futures-channel-0.3.28/tests/mpsc-size_hint.rs
wasmtime-14.0.3 ./ext/cargo-vendor/futures-channel-0.3.28/tests/mpsc-size_hint.rs