Diffstat (limited to 'src/effect/async.rs')
| -rw-r--r-- | src/effect/async.rs | 71 |
1 files changed, 27 insertions, 44 deletions
diff --git a/src/effect/async.rs b/src/effect/async.rs index ffe8bb7..effcd08 100644 --- a/src/effect/async.rs +++ b/src/effect/async.rs @@ -21,7 +21,7 @@ use pin_project::pin_project; use crate::hkt::Marker; -use super::{Effect, Effective, ErasedEffective, ErasedForLt, Join, TryJoin}; +use super::{Effect, Effective, ErasedEffective, ErasedForLt, Join, Ss, TryJoin}; pub enum Async {} @@ -40,38 +40,38 @@ pub enum BoxOrReady<'a, T> { pub type BoxedFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + Sync + 'a>>; -impl<'a, T: Send + Sync, O> ErasedForLt<'a, T, Async, &'a (T, O), O> for ErasedHrt<T> { +impl<'a, T: Ss, O> ErasedForLt<'a, T, Async, &'a (T, O), O> for ErasedHrt<T> { type T = BoxOrReady<'a, T>; } -impl<T: Send + Sync> super::ErasedHrt<T, Async> for ErasedHrt<T> { +impl<T: Ss> super::ErasedHrt<T, Async> for ErasedHrt<T> { type T<B> = ErasedHrt<T>; } impl Effect for Async { - type Erased<T: Send + Sync> = ErasedHrt<T>; + type Erased<T: Ss> = ErasedHrt<T>; - type Ready<'a, T: Send + Sync + 'a> = Value<T>; + type Ready<'a, T: Ss + 'a> = Value<T>; - fn ready<'a, T: Send + Sync + 'a>(value: T) -> Self::Ready<'a, T> { + fn ready<'a, T: Ss + 'a>(value: T) -> Self::Ready<'a, T> { Value(value) } - type FromFuture<'a, F: Send + Sync + 'a> = Shim<F> + type FromFuture<'a, F: Ss + 'a> = Shim<F> where F: futures::prelude::Future, - F::Output: Send + Sync + 'a; + F::Output: Ss + 'a; - fn from_future<'a, F: Send + Sync + 'a>(future: F) -> Self::FromFuture<'a, F> + fn from_future<'a, F: Ss + 'a>(future: F) -> Self::FromFuture<'a, F> where F: futures::prelude::Future, - F::Output: Send + Sync + 'a, + F::Output: Ss + 'a, { Shim::new(future) } } -impl<'lt, U: Send + Sync + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { +impl<'lt, U: Ss + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { fn into_erased<B>(self) -> super::ErasedEffective<'lt, Self::Output, Self::Effect, B> { self } @@ -89,13 +89,13 @@ impl<'lt, U: Send + Sync + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { } } - type Loop<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a> + type Loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a> = BoxOrReady<'a, (U, T)> where F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>, 'lt: 'a; - fn r#loop<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a>(self, mut cb: F) -> Self::Loop<'ctx, 'a, T, F> + fn r#loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, mut cb: F) -> Self::Loop<'ctx, 'a, T, F> where F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>, 'lt: 'a, @@ -111,12 +111,12 @@ impl<'lt, U: Send + Sync + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { })) } - type Map<'a, T: Send + Sync + 'a, F: Send + Sync + 'a> = Map<ErasedFuture<'lt, U>, F> + type Map<'a, T: Ss + 'a, F: Ss + 'a> = Map<ErasedFuture<'lt, U>, F> where F: FnOnce(Self::Output) -> T, 'lt: 'a; - fn map<'a, T: Send + Sync + 'a, F: Send + Sync + 'a>(self, cb: F) -> Self::Map<'a, T, F> + fn map<'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Map<'a, T, F> where F: FnOnce(Self::Output) -> T, 'lt: 'a, @@ -124,17 +124,14 @@ impl<'lt, U: Send + Sync + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { Map::new(self.into_future(), cb) } - type Then<'a, T: Send + Sync + 'a, V: Send + Sync + 'a, F: Send + Sync + 'a> + type Then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a> = Then<'a, ErasedFuture<'lt, U>, F, V> where F: FnOnce(Self::Output) -> V, V: Effective<'a, Output = T, Effect = Self::Effect>, 'lt: 'a; - fn then<'a, T: Send + Sync + 'a, V: Send + Sync + 'a, F: Send + Sync + 'a>( - self, - cb: F, - ) -> Self::Then<'a, T, V, F> + fn then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Then<'a, T, V, F> where F: FnOnce(Self::Output) -> V, V: Effective<'a, Output = T, Effect = Self::Effect>, @@ -143,13 +140,13 @@ impl<'lt, U: Send + Sync + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { Then::new(self.into_future(), cb) } - type AsCtx<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a> + type AsCtx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a> = BoxOrReady<'a, (Self::Output, T)> where F: for<'b> FnOnce(&'b mut Self::Output) -> super::ErasedEffective<'b, T, Self::Effect>, 'lt: 'a; - fn as_ctx<'ctx: 'a, 'a, T: Send + Sync + 'a, F: Send + Sync + 'a>(self, cb: F) -> Self::AsCtx<'ctx, 'a, T, F> + fn as_ctx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::AsCtx<'ctx, 'a, T, F> where F: for<'b> FnOnce(&'b mut Self::Output) -> super::ErasedEffective<'b, T, Self::Effect>, 'lt: 'a, @@ -167,20 +164,20 @@ impl<'lt, U: Send + Sync + 'lt> Effective<'lt> for BoxOrReady<'lt, U> { impl Join for Async { type Effect = Self; - type Two<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a> + type Two<'a, T0: Ss + 'a, T1: Ss + 'a> = Shim<futures::future::Join<T0::IntoFuture, T1::IntoFuture>> where T0: super::Effective<'a, Effect = Self::Effect>, T1: super::Effective<'a, Effect = Self::Effect>; - type Three<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a, T2: Send + Sync + 'a> + type Three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a> = Shim<futures::future::Join3<T0::IntoFuture, T1::IntoFuture, T2::IntoFuture, >> where T0: super::Effective<'a, Effect = Self::Effect>, T1: super::Effective<'a, Effect = Self::Effect>, T2: super::Effective<'a, Effect = Self::Effect>; - fn two<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a>(cb: (T0, T1)) -> Self::Two<'a, T0, T1> + fn two<'a, T0: Ss + 'a, T1: Ss + 'a>(cb: (T0, T1)) -> Self::Two<'a, T0, T1> where T0: super::Effective<'a, Effect = Self::Effect>, T1: super::Effective<'a, Effect = Self::Effect>, @@ -191,7 +188,7 @@ impl Join for Async { )) } - fn three<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a, T2: Send + Sync + 'a>( + fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a>( cb: (T0, T1, T2), ) -> Self::Three<'a, T0, T1, T2> where @@ -210,26 +207,20 @@ impl Join for Async { impl TryJoin for Async { type Effect = Self; - type Two<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a> + type Two<'a, T0: Ss + 'a, T1: Ss + 'a> = Shim<futures::future::TryJoin<BoxedFuture<'a, T0::Output>, BoxedFuture<'a, T1::Output>>> where T0: super::TryEffective<'a, Effect = Self::Effect>, T1: super::TryEffective<'a, Err = T0::Err, Effect = Self::Effect>; - type Three<'a, T0: Send + Sync + 'a, T1: Send + Sync + 'a, T2: Send + Sync + 'a> + type Three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a> = Shim<futures::future::TryJoin3<BoxedFuture<'a, T0::Output>, BoxedFuture<'a, T1::Output>, BoxedFuture<'a, T2::Output>>> where T0: super::TryEffective<'a, Effect = Self::Effect>, T1: super::TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, T2: super::TryEffective<'a, Err = T0::Err, Effect = Self::Effect>; - fn two< - 'a, - T0: Send + Sync + 'a, - T1: Send + Sync + 'a, - F0: Send + Sync + 'a, - F1: Send + Sync + 'a, - >( + fn two<'a, T0: Ss + 'a, T1: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a>( cb: (F0, F1), ) -> Self::Two<'a, T0, T1> where @@ -244,15 +235,7 @@ impl TryJoin for Async { )) } - fn three< - 'a, - T0: Send + Sync + 'a, - T1: Send + Sync + 'a, - T2: Send + Sync + 'a, - F0: Send + Sync + 'a, - F1: Send + Sync + 'a, - F2: Send + Sync + 'a, - >( + fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a, F2: Ss + 'a>( cb: (F0, F1, F2), ) -> Self::Three<'a, T0, T1, T2> where |