use fut::Stream; use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; pub struct FutResult(T); impl Future for FutResult { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { loop {} } } mod fut { use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; pub trait Stream { type Item; fn map(self, f: F) -> Map where F: FnMut(Self::Item) -> T, Self: Sized, { loop {} } fn for_each(self, f: F) -> ForEach where F: FnMut(Self::Item) -> Fut, Fut: Future, Self: Sized, { loop {} } } pub fn map(f: F) -> Map where F: FnMut(String) -> T, { loop {} } pub struct Map(F); 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 { loop {} } } impl Stream for Map where F: FnOnce1, F::Output: Future, { type Item = ::Output; } pub struct ForEach { stream: St, f: F, future: Option, } impl Future for ForEach where St: Stream, F: FnMut(St::Item) -> Fut, Fut: Future, { type Output = (); fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { loop {} } } } fn main() { let bodies = fut::map(|url| FutResult(Result::Ok(url))); bodies.for_each(|b| async { match b { Ok(Ok(url)) => {} Err(e) => {} Ok(Err(e)) => {} } }); }