Diffstat (limited to 'tests/hook.rs')
-rw-r--r--tests/hook.rs37
1 files changed, 24 insertions, 13 deletions
diff --git a/tests/hook.rs b/tests/hook.rs
index 7746ab1..9dacb62 100644
--- a/tests/hook.rs
+++ b/tests/hook.rs
@@ -1,12 +1,14 @@
-use std::{future::Future, marker::PhantomData, pin::Pin, thread::yield_now, time::Duration, ops::ControlFlow};
+use std::{
+ future::Future, marker::PhantomData, ops::ControlFlow, pin::Pin, thread::yield_now,
+ time::Duration,
+};
use treaty::{
any::{any_trait, static_wrapper::OwnedStatic, AnyTrait, IndirectLtAny, LtTypeId},
- build_with, into_walker,
- protocol::{
- any_t, as_obj, visitor::Value, AsObj, AsyncEffect, Yield, Effect, SyncEffect,
- Visitor, EffectAnyTrait,
- },
+ build_with,
+ effect::{any_t, as_obj, AsObj, AsyncEffect, Effect, EffectAnyTrait, SyncEffect, Yield},
+ into_walker,
+ protocol::{visitor::Value, Visitor},
Build, Builder, Walker,
};
@@ -16,7 +18,9 @@ fn demo() {
inner: into_walker(true),
_marker: PhantomData,
};
- let x = build_with::<<bool as Build<_>>::Builder, _>(hook).unwrap();
+ // let x = build_with::<<bool as Build<_>>::Builder, _>(hook).unwrap();
+ // dbg!(x);
+ let x = build_with::<<Option<bool> as Build<_>>::Builder, _>(hook).unwrap();
dbg!(x);
todo!();
}
@@ -89,7 +93,9 @@ impl<'ctx, T: Walker<'ctx, Effect = SyncEffect>> Walker<'ctx> for Hook<T, SyncEf
}
}
-impl<'b, 'ctx: 'b, E: Effect<'ctx, ControlFlow<(), ()>>> AnyTrait<'ctx> for VisitorHook<'b, 'ctx, E> {
+impl<'b, 'ctx: 'b, E: Effect<'ctx, ControlFlow<(), ()>>> AnyTrait<'ctx>
+ for VisitorHook<'b, 'ctx, E>
+{
fn upcast_to_id<'a>(
&'a self,
id: treaty::any::LtTypeId<'ctx>,
@@ -111,10 +117,10 @@ impl<'b, 'ctx: 'b, E: Effect<'ctx, ControlFlow<(), ()>>> AnyTrait<'ctx> for Visi
'ctx: 'a,
{
match id {
- id if id == LtTypeId::of::<dyn Value<'ctx, OwnedStatic<bool>, E> + 'a>() => {
+ id if id == LtTypeId::of::<dyn Value<'_, 'ctx, OwnedStatic<bool>, E> + 'a>() => {
if self.inner.as_obj_mut().upcast_to_id_mut(id).is_some() {
Some(IndirectLtAny::<'a, 'ctx, _>::new::<
- dyn Value<'ctx, OwnedStatic<bool>, E> + 'a,
+ dyn Value<'_, 'ctx, OwnedStatic<bool>, E> + 'a,
>(self as _))
} else {
None
@@ -125,16 +131,21 @@ impl<'b, 'ctx: 'b, E: Effect<'ctx, ControlFlow<(), ()>>> AnyTrait<'ctx> for Visi
}
}
-impl<'b, 'ctx: 'b, E: Effect<'ctx, ControlFlow<(), ()>>> Value<'ctx, OwnedStatic<bool>, E> for VisitorHook<'b, 'ctx, E> {
+impl<'a, 'b, 'ctx: 'b + 'a, E: Effect<'ctx, ControlFlow<(), ()>>> Value<'a, 'ctx, OwnedStatic<bool>, E>
+ for VisitorHook<'b, 'ctx, E>
+{
#[inline]
- fn visit<'a>(&'a mut self, OwnedStatic(value): OwnedStatic<bool>) -> Yield<'a, 'ctx, ControlFlow<(), ()>, E>
+ fn visit(
+ &'a mut self,
+ OwnedStatic(value): OwnedStatic<bool>,
+ ) -> Yield<'a, 'ctx, ControlFlow<(), ()>, E>
where
'ctx: 'a,
{
let visitor = self
.inner
.as_obj_mut()
- .upcast_mut::<dyn Value<'ctx, OwnedStatic<bool>, E> + 'a>()
+ .upcast_mut::<dyn Value<'a, 'ctx, OwnedStatic<bool>, E> + 'a>()
.unwrap();
// println!("Hooked bool: {}", value);