ice-104649/src/main.rs
2022-11-20 20:52:54 +01:00

35 lines
684 B
Rust

use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use futures::{stream, StreamExt};
pub struct JoinHandle<T>(T);
impl<T> Future for JoinHandle<T> {
type Output = Result<T, ()>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {}
}
}
pub fn spawn<T: Future>(future: T) -> JoinHandle<T::Output> {
loop {}
}
fn main() {
let bodies = stream::iter([])
.map(|url: String| spawn(async { Result::Ok(url) }))
.buffer_unordered(0);
bodies.for_each(|b| async {
match b {
Ok(Ok(url)) => {}
Err(e) => {}
Ok(Err(e)) => {}
}
});
}