mirror of
https://github.com/Noratrieb/ice-104649.git
synced 2026-01-14 12:35:02 +01:00
simplify
This commit is contained in:
parent
58cfda5ac1
commit
9db8176c8b
1 changed files with 8 additions and 9 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -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) => {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue