// run-pass #![allow(unused_must_use)] fn main() { if false { test(); } } fn test() { let rx = Err::, u32>(1).into_future(); rx.map(|l: Vec| stream::iter(l.into_iter().map(|i| Ok(i)))) .flatten_stream() .chunks(50) .buffer_unordered(5); } use future::{Future, IntoFuture}; mod future { use std::result; use {stream, Stream}; pub trait Future { type Item; type Error; fn map(self, _: F) -> Map where F: FnOnce(Self::Item) -> U, Self: Sized, { panic!() } fn flatten_stream(self) -> FlattenStream where ::Item: stream::Stream, Self: Sized { panic!() } } pub trait IntoFuture { type Future: Future; type Item; type Error; fn into_future(self) -> Self::Future; } impl IntoFuture for F { type Future = F; type Item = F::Item; type Error = F::Error; fn into_future(self) -> F { panic!() } } impl IntoFuture for result::Result { type Future = FutureResult; type Item = T; type Error = E; fn into_future(self) -> FutureResult { panic!() } } pub struct Map { _a: (A, F), } impl Future for Map where A: Future, F: FnOnce(A::Item) -> U, { type Item = U; type Error = A::Error; } pub struct FlattenStream { _f: F, } impl Stream for FlattenStream where F: Future, ::Item: Stream, { type Item = ::Item; type Error = ::Error; } pub struct FutureResult { _inner: (T, E), } impl Future for FutureResult { type Item = T; type Error = E; } } mod stream { use IntoFuture; pub trait Stream { type Item; type Error; fn buffer_unordered(self, amt: usize) -> BufferUnordered where Self::Item: IntoFuture::Error>, Self: Sized { new(self, amt) } fn chunks(self, _capacity: usize) -> Chunks where Self: Sized { panic!() } } pub struct IterStream { _iter: I, } pub fn iter(_: J) -> IterStream where J: IntoIterator>, { panic!() } impl Stream for IterStream where I: Iterator>, { type Item = T; type Error = E; } pub struct Chunks { _stream: S } impl Stream for Chunks where S: Stream { type Item = Result::Item>, u32>; type Error = ::Error; } pub struct BufferUnordered { _stream: S, } enum Slot { Next(#[allow(unused_tuple_struct_fields)] usize), _Data { _a: T }, } fn new(_s: S, _amt: usize) -> BufferUnordered where S: Stream, S::Item: IntoFuture::Error>, { (0..0).map(|_| { Slot::Next::<::Future>(1) }).collect::>(); panic!() } impl Stream for BufferUnordered where S: Stream, S::Item: IntoFuture::Error>, { type Item = ::Item; type Error = ::Error; } } use stream::Stream;