mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-14 12:35:02 +01:00
35 lines
684 B
Rust
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)) => {}
|
|
}
|
|
});
|
|
}
|