future_combinator_params/
lib.rs1use futures::Future;
2use std::fmt::Debug;
3use std::{boxed::Box, pin::Pin};
4
5pub fn combine_param<R, T, E>(
6 t: T,
7) -> impl FnOnce(Result<R, E>) -> Pin<Box<dyn Future<Output = Result<(R, T), E>> + Sync + Send>>
8where
9 R: Sized + 'static + Sync + Send,
10 T: Sized + 'static + Sync + Send,
11 E: Sized + 'static + Debug + Sync + Send,
12{
13 |r: Result<R, E>| Box::pin(async { Ok((r?, t)) })
14}
15
16pub fn combine_flat_param<R, T, E>(
17 t: T,
18) -> impl FnOnce(R) -> Pin<Box<dyn Future<Output = Result<(R, T), E>> + Sync + Send>>
19where
20 R: Sized + 'static + Sync + Send,
21 T: Sized + 'static + Sync + Send,
22 E: Sized + 'static + Debug + Sync + Send,
23{
24 |r: R| Box::pin(async { Ok((r, t)) })
25}