mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-16 13:25:03 +01:00
simplify
This commit is contained in:
parent
a572c048c9
commit
79e9aa8d4f
1 changed files with 9 additions and 9 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -1,37 +1,37 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use futures::{stream, StreamExt, Future};
|
use futures::{stream, Future, StreamExt};
|
||||||
|
|
||||||
pub struct JoinHandle<T> {
|
pub struct JoinHandle<T> {
|
||||||
raw: Option<()>,
|
|
||||||
id: u64,
|
|
||||||
_p: PhantomData<T>,
|
_p: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Future for JoinHandle<T> {
|
impl<T> Future for JoinHandle<T> {
|
||||||
type Output = Result<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 {}
|
loop {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
|
pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
|
||||||
where
|
where
|
||||||
T: Future + Send + 'static,
|
T: Future,
|
||||||
T::Output: Send + 'static,
|
|
||||||
{
|
{
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let bodies = stream::iter([])
|
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);
|
.buffer_unordered(0);
|
||||||
|
|
||||||
bodies.for_each(|b| async {
|
bodies.for_each(|b| async {
|
||||||
match b {
|
match b {
|
||||||
Ok(Ok((url, b))) => {}
|
Ok(Ok(url)) => {}
|
||||||
Err(e) => {}
|
Err(e) => {}
|
||||||
Ok(Err(e)) => {}
|
Ok(Err(e)) => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue