Diffstat (limited to 'src/build/builders/core/value.rs')
-rw-r--r--src/build/builders/core/value.rs78
1 files changed, 50 insertions, 28 deletions
diff --git a/src/build/builders/core/value.rs b/src/build/builders/core/value.rs
index ccca07e..cd25bdc 100644
--- a/src/build/builders/core/value.rs
+++ b/src/build/builders/core/value.rs
@@ -1,6 +1,12 @@
use core::fmt::Display;
-use effectful::{bound::IsSync, closure::Capture, effective::Effective, environment::{DynBind, Environment, NativeForm}, forward_send_sync, higher_ranked::Mut};
+use effectful::{
+ bound::IsSync,
+ effective::Effective,
+ environment::{DynBind, Environment, NativeForm},
+ forward_send_sync,
+ higher_ranked::Mut,
+};
use crate::{
any::{
@@ -54,9 +60,9 @@ pub struct ValueBuilder<T, Clone, E> {
forward_send_sync!({T} {} {Clone, E} ValueBuilder<T, Clone, E>);
-impl<T, Clone, E: Environment> crate::BuilderTypes<E> for ValueBuilder<T, Clone, E>
+impl<T, Clone, E: Environment> crate::BuilderTypes<E> for ValueBuilder<T, Clone, E>
where
- T: DynBind<E>
+ T: DynBind<E>,
{
type Error = ValueError<T>;
@@ -68,7 +74,7 @@ where
impl<'ctx, T: 'static, Clone, E: Environment> crate::Builder<'ctx, E> for ValueBuilder<T, Clone, E>
where
Self: AnyTrait<'ctx, E>,
- T: DynBind<E>
+ T: DynBind<E>,
{
fn build<'a>(self) -> NativeForm<'a, Result<Self::Value, Self::Error>, E>
where
@@ -84,7 +90,8 @@ where
E::value(Self {
value: None,
_marker: Default::default(),
- }).cast()
+ })
+ .cast()
}
}
@@ -122,9 +129,9 @@ any_trait! {
T: DynBind<E> + IsSync<E::NeedSend> + 'static + Clone,
}
-impl<'ctx, T: 'static, E: Environment> RequestHint<'ctx, E> for ValueBuilder<T, NotCloneable, E>
+impl<'ctx, T: 'static, E: Environment> RequestHint<'ctx, E> for ValueBuilder<T, NotCloneable, E>
where
- T: DynBind<E> + IsSync<E::NeedSend>
+ T: DynBind<E> + IsSync<E::NeedSend>,
{
fn request_hint<'this: 'e, 'walker: 'e, 'e>(
&'this mut self,
@@ -133,9 +140,11 @@ where
where
'ctx: 'this + 'walker,
{
- E::with(Capture((self, walker)).lending_fun_mut(|(this, walker), _| {
+ E::with((self, walker), |(this, walker)| {
hint_protocol::<ValueProto<OwnedStatic<T>, E>, _>(walker.cast(), *this, ()).cast()
- })).cast()
+ })
+ .map((), |_, (_, x)| x)
+ .cast()
}
}
@@ -151,33 +160,46 @@ where
'ctx: 'this + 'walker,
{
E::value((self, walker))
- .update(Capture(()).fun_once_hrt::<Mut<_>, _>(|_, (this, walker), _| {
- hint_protocol::<ValueProto<OwnedStatic<T>, E>, _>(walker.cast(), *this, ()).cast()
- }))
- .if_not_finished(|(this, walker)| {
- hint_protocol::<ValueProto<BorrowedStaticHrt<T>, E>, _>(walker.cast(), *this, ()).cast()
- })
- .if_not_finished(|(this, walker)| {
- hint_protocol::<ValueProto<TempBorrowedStaticHrt<T>, E>, _>(walker.cast(), *this, ())
- .cast()
- })
- .if_not_finished(|(this, walker)| {
- hint_protocol::<ValueProto<BorrowedMutStaticHrt<T>, E>, _>(walker.cast(), *this, ())
+ .update((), |_, (this, walker)| {
+ hint_protocol::<ValueProto<OwnedStatic<T>, E>, _>(walker.cast(), *this, ()).cast()
+ })
+ .cast::<()>()
+ .if_not_finished((), |_, (this, walker)| {
+ hint_protocol::<ValueProto<BorrowedStaticHrt<T>, E>, _>(walker.cast(), *this, ())
+ .cast()
+ })
+ .cast::<()>()
+ .if_not_finished((), |_, (this, walker)| {
+ hint_protocol::<ValueProto<TempBorrowedStaticHrt<T>, E>, _>(
+ walker.cast(),
+ *this,
+ (),
+ )
.cast()
- })
- .if_not_finished(|(this, walker)| {
- hint_protocol::<ValueProto<TempBorrowedMutStaticHrt<T>, E>, _>(walker.cast(), *this, ())
+ })
+ .cast::<()>()
+ .if_not_finished((), |_, (this, walker)| {
+ hint_protocol::<ValueProto<BorrowedMutStaticHrt<T>, E>, _>(walker.cast(), *this, ())
+ .cast()
+ })
+ .cast::<()>()
+ .if_not_finished((), |_, (this, walker)| {
+ hint_protocol::<ValueProto<TempBorrowedMutStaticHrt<T>, E>, _>(
+ walker.cast(),
+ *this,
+ (),
+ )
.cast()
- })
- .map(Capture(()).fun_once(|_, (_, x), _| x))
- .cast()
+ })
+ .map((), |_, (_, x)| x)
+ .cast()
}
}
impl<'ctx, T: 'static, Clone, E: Environment> Value<'ctx, OwnedStatic<T>, E>
for ValueBuilder<T, Clone, E>
where
- T: DynBind<E>
+ T: DynBind<E>,
{
fn visit<'a>(
&'a mut self,