This commit is contained in:
nora 2022-11-20 22:19:39 +01:00
parent 58cfda5ac1
commit 9db8176c8b
No known key found for this signature in database

View file

@ -11,7 +11,7 @@ impl<T> Project for Wrap<T> {
pub trait Stream { pub trait Stream {
type Item; type Item;
fn for_each<Fut, F>(self, f: F) fn async_match_on_projected<Fut, F>(self, f: F)
where where
F: FnMut(Self::Item) -> Fut, F: FnMut(Self::Item) -> Fut,
Self: Sized, Self: Sized,
@ -20,21 +20,21 @@ pub trait Stream {
} }
} }
pub struct Map<F>(F); pub struct ProjectFnOutput<F>(F);
impl<F> Stream for Map<F> impl<F> Stream for ProjectFnOutput<F>
where where
F: FnOnce1, F: GetFnOutput,
F::Output: Project, F::Output: Project,
{ {
type Item = <F::Output as Project>::Assoc; type Item = <F::Output as Project>::Assoc;
} }
pub trait FnOnce1 { pub trait GetFnOutput {
type Output; type Output;
} }
impl<T, R> FnOnce1 for T impl<T, R> GetFnOutput for T
where where
T: FnOnce() -> R, T: FnOnce() -> R,
{ {
@ -42,9 +42,8 @@ where
} }
fn main() { fn main() {
let bodies = Map(|| Wrap(Result::Ok(()))); let proj = ProjectFnOutput(|| Wrap(Result::Ok(())));
proj.async_match_on_projected(|b| async {
bodies.for_each(|b| async {
match b { match b {
Ok(Ok(url)) => {} Ok(Ok(url)) => {}
Err(e) => {} Err(e) => {}