mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-15 13:05:02 +01:00
lol no futures
This commit is contained in:
parent
592e86e3f3
commit
4433f6b891
1 changed files with 39 additions and 45 deletions
84
src/main.rs
84
src/main.rs
|
|
@ -10,65 +10,59 @@ impl<T> Project for FutResult<T> {
|
|||
type Assoc = Result<T, ()>;
|
||||
}
|
||||
|
||||
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<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>
|
||||
where
|
||||
F: FnMut(Self::Item) -> Fut,
|
||||
Fut: Future<Output = ()>,
|
||||
Self: Sized,
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map<T, F>(f: F) -> Map<F>
|
||||
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, F>
|
||||
where
|
||||
F: FnMut(String) -> T,
|
||||
F: FnMut(Self::Item) -> Fut,
|
||||
Self: Sized,
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Map<F>(F);
|
||||
pub fn map<T, F>(f: F) -> Map<F>
|
||||
where
|
||||
F: FnMut(String) -> T,
|
||||
{
|
||||
loop {}
|
||||
}
|
||||
|
||||
pub trait FnOnce1<A> {
|
||||
type Output;
|
||||
fn call_once(self, arg: A) -> Self::Output;
|
||||
}
|
||||
pub struct Map<F>(F);
|
||||
|
||||
impl<T, A, R> FnOnce1<A> for T
|
||||
where
|
||||
T: FnOnce(A) -> R,
|
||||
{
|
||||
type Output = R;
|
||||
fn call_once(self, arg: A) -> R {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
pub trait FnOnce1<A> {
|
||||
type Output;
|
||||
fn call_once(self, arg: A) -> Self::Output;
|
||||
}
|
||||
|
||||
impl<F> Stream for Map<F>
|
||||
where
|
||||
F: FnOnce1<String>,
|
||||
F::Output: Project,
|
||||
{
|
||||
type Item = <F::Output as Project>::Assoc;
|
||||
}
|
||||
|
||||
pub struct ForEach<St, Fut, F> {
|
||||
stream: St,
|
||||
f: F,
|
||||
future: Fut,
|
||||
impl<T, A, R> FnOnce1<A> for T
|
||||
where
|
||||
T: FnOnce(A) -> R,
|
||||
{
|
||||
type Output = R;
|
||||
fn call_once(self, arg: A) -> R {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<F> Stream for Map<F>
|
||||
where
|
||||
F: FnOnce1<String>,
|
||||
F::Output: Project,
|
||||
{
|
||||
type Item = <F::Output as Project>::Assoc;
|
||||
}
|
||||
|
||||
pub struct ForEach<St, F> {
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue