|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
use std::convert::identity;
|
|
|
|
|
use std::marker::Unpin;
|
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
use std::task::{Context, Poll};
|
|
|
|
|
|
|
|
|
@ -99,15 +101,6 @@ fn merge_works_with_unfused_streams() {
|
|
|
|
|
assert_eq!(xs, vec![92, 92]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn flat_map_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
async_std::task::block_on(async {
|
|
|
|
|
use async_std::prelude::*;
|
|
|
|
|
use async_std::task::*;
|
|
|
|
|
use std::convert::identity;
|
|
|
|
|
use std::marker::Unpin;
|
|
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
|
|
|
|
struct S<T>(T);
|
|
|
|
|
|
|
|
|
|
impl<T: Stream + Unpin> Stream for S<T> {
|
|
|
|
@ -120,7 +113,7 @@ fn flat_map_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
|
|
|
|
|
struct StrictOnce {
|
|
|
|
|
polled: bool,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Stream for StrictOnce {
|
|
|
|
|
type Item = ();
|
|
|
|
@ -134,7 +127,7 @@ fn flat_map_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
|
|
|
|
|
struct Interchanger {
|
|
|
|
|
polled: bool,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Stream for Interchanger {
|
|
|
|
|
type Item = S<Box<dyn Stream<Item = ()> + Unpin>>;
|
|
|
|
@ -151,6 +144,9 @@ fn flat_map_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn flat_map_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
task::block_on(async {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
Interchanger { polled: false }
|
|
|
|
|
.take(2)
|
|
|
|
@ -161,3 +157,17 @@ fn flat_map_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn flatten_doesnt_poll_completed_inner_stream() {
|
|
|
|
|
task::block_on(async {
|
|
|
|
|
assert_eq!(
|
|
|
|
|
Interchanger { polled: false }
|
|
|
|
|
.take(2)
|
|
|
|
|
.flatten()
|
|
|
|
|
.count()
|
|
|
|
|
.await,
|
|
|
|
|
0
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|