// incremental // edition: 2021 use std::future::*; use std::marker::PhantomData; use std::pin::Pin; use std::task::*; fn send(_: T) {} pub trait Stream { type Item; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>; } struct Empty(PhantomData T>); impl Stream for Empty { type Item = T; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { todo!() } } pub trait FnOnce1 { type Output; fn call_once(self, arg: A) -> Self::Output; } impl FnOnce1 for T where T: FnOnce(A) -> R, { type Output = R; fn call_once(self, arg: A) -> R { self(arg) } } pub trait FnMut1: FnOnce1 { fn call_mut(&mut self, arg: A) -> Self::Output; } impl FnMut1 for T where T: FnMut(A) -> R, { fn call_mut(&mut self, arg: A) -> R { self(arg) } } struct Map(St, F); impl Stream for Map where St: Stream, F: FnMut1, { type Item = F::Output; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { todo!() } } struct FuturesOrdered(PhantomData T::Output>); pub struct Buffered(St, FuturesOrdered, usize) where St::Item: Future; impl Stream for Buffered where St: Stream, St::Item: Future, { type Item = ::Output; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { todo!() } } struct Next<'a, T: ?Sized>(&'a T); impl Future for Next<'_, St> { type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { todo!() } } fn main() { send(async { //~^ ERROR implementation of `FnOnce` is not general enough //~| ERROR implementation of `FnOnce` is not general enough Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrdered(PhantomData), 0)).await }); }