From 4433f6b891c2599b48959df2cf4aed695c42d0f5 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 20 Nov 2022 22:09:54 +0100 Subject: [PATCH] lol no futures --- src/main.rs | 84 +++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 45 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5b1fb5f..113a4ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,65 +10,59 @@ impl Project for FutResult { type Assoc = Result; } -mod fut { - use std::future::Future; +use crate::Project; - use crate::Project; +pub trait Stream { + type Item; - pub trait Stream { - type Item; - - fn for_each(self, f: F) -> ForEach - where - F: FnMut(Self::Item) -> Fut, - Fut: Future, - Self: Sized, - { - loop {} - } - } - - pub fn map(f: F) -> Map + fn for_each(self, f: F) -> ForEach where - F: FnMut(String) -> T, + F: FnMut(Self::Item) -> Fut, + Self: Sized, { loop {} } +} - pub struct Map(F); +pub fn map(f: F) -> Map +where + F: FnMut(String) -> T, +{ + loop {} +} - pub trait FnOnce1 { - type Output; - fn call_once(self, arg: A) -> Self::Output; - } +pub struct Map(F); - impl FnOnce1 for T - where - T: FnOnce(A) -> R, - { - type Output = R; - fn call_once(self, arg: A) -> R { - loop {} - } - } +pub trait FnOnce1 { + type Output; + fn call_once(self, arg: A) -> Self::Output; +} - impl Stream for Map - where - F: FnOnce1, - F::Output: Project, - { - type Item = ::Assoc; - } - - pub struct ForEach { - stream: St, - f: F, - future: Fut, +impl FnOnce1 for T +where + T: FnOnce(A) -> R, +{ + type Output = R; + fn call_once(self, arg: A) -> R { + loop {} } } +impl Stream for Map +where + F: FnOnce1, + F::Output: Project, +{ + type Item = ::Assoc; +} + +pub struct ForEach { + stream: St, + f: F, +} + fn main() { - let bodies = fut::map(|url| FutResult(Result::Ok(url))); + let bodies = map(|url| FutResult(Result::Ok(url))); bodies.for_each(|b| async { match b {