This commit is contained in:
nora 2022-11-20 20:32:01 +01:00
parent a572c048c9
commit 79e9aa8d4f
No known key found for this signature in database

View file

@ -1,37 +1,37 @@
use std::marker::PhantomData;
use futures::{stream, StreamExt, Future};
use futures::{stream, Future, StreamExt};
pub struct JoinHandle<T> {
raw: Option<()>,
id: u64,
_p: PhantomData<T>,
}
impl<T> Future for JoinHandle<T> {
type Output = Result<T, ()>;
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
fn poll(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
loop {}
}
}
pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
T: Future,
{
loop {}
loop {}
}
fn main() {
let bodies = stream::iter([])
.map(|url: String| spawn(async move { Result::Ok((url, "A".to_owned())) }))
.map(|url: String| spawn(async { Result::Ok(url) }))
.buffer_unordered(0);
bodies.for_each(|b| async {
match b {
Ok(Ok((url, b))) => {}
Ok(Ok(url)) => {}
Err(e) => {}
Ok(Err(e)) => {}
}