From 272b2d844f8a9d67435aa788acb0acb2d3a0af63 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 20 Nov 2022 22:00:50 +0100 Subject: [PATCH] lol no futures --- src/main.rs | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/main.rs b/src/main.rs index 99c4eeb..25eeeba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,9 +5,9 @@ use std::{ task::{Context, Poll}, }; -pub struct JoinHandle(T); +pub struct FutResult(T); -impl Future for JoinHandle { +impl Future for FutResult { type Output = Result; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { @@ -15,10 +15,6 @@ impl Future for JoinHandle { } } -pub fn spawn(future: T) -> JoinHandle { - loop {} -} - mod fut { use std::{ future::Future, @@ -46,7 +42,7 @@ mod fut { loop {} } - fn buffer_unordered(self, n: impl Into>) -> BufferUnordered + fn buffer_unordered(self) -> BufferUnordered where Self::Item: Future, Self: Sized, @@ -55,24 +51,10 @@ mod fut { } } - pub struct Iter { - iter: I, - } + pub struct Empty; - pub fn iter(i: I) -> Iter - where - I: IntoIterator, - { - Iter { - iter: i.into_iter(), - } - } - - impl Stream for Iter - where - I: Iterator, - { - type Item = I::Item; + impl Stream for Empty { + type Item = String; } pub struct Map { @@ -139,9 +121,9 @@ mod fut { } fn main() { - let bodies = fut::iter([]) - .map(|url: String| spawn(Result::Ok(url))) - .buffer_unordered(0); + let bodies = fut::Empty + .map(|url| FutResult(Result::Ok(url))) + .buffer_unordered(); bodies.for_each(|b| async { match b {