Diffstat (limited to 'src/build/builders/debug.rs')
| -rw-r--r-- | src/build/builders/debug.rs | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/src/build/builders/debug.rs b/src/build/builders/debug.rs index 54efc96..68d9de6 100644 --- a/src/build/builders/debug.rs +++ b/src/build/builders/debug.rs @@ -1,13 +1,9 @@ -use core::{any::TypeId, marker::PhantomData, ops::ControlFlow}; +use core::{any::TypeId, marker::PhantomData}; use crate::{ - any::{ - static_wrapper::{DynOwnedStatic, OwnedStatic}, - TypeNameId, - }, + any::static_wrapper::{DynOwnedStatic, OwnedStatic}, any_trait, effect::{Effect, Future}, - never::Never, protocol::{ self, visitor::{ @@ -38,10 +34,16 @@ any_trait! { let id; println!("Unknown trait: {:?}", id); None - } where E: Effect<'ctx> + } where E: Effect +} + +impl<E: Effect> Default for Visitor<E> { + fn default() -> Self { + Self::new() + } } -impl<'ctx, E: Effect<'ctx>> Visitor<E> { +impl<E: Effect> Visitor<E> { pub fn new() -> Self { Self(0, PhantomData) } @@ -56,11 +58,11 @@ impl<'ctx, E: Effect<'ctx>> Visitor<E> { } } -impl<'ctx, E: Effect<'ctx>> RequestHint<'ctx, E> for Visitor<E> { +impl<'ctx, E: Effect> RequestHint<'ctx, E> for Visitor<E> { fn request_hint<'a>( &'a mut self, _walker: crate::protocol::Walker<'a, 'ctx>, - ) -> Future<'a, 'ctx, Flow, E> { + ) -> Future<'a, Flow, E> { // self.tab(); // println!("Visit request hint (no hint given)"); // println!("Visit request hint (hint for recoverable)"); @@ -68,12 +70,12 @@ impl<'ctx, E: Effect<'ctx>> RequestHint<'ctx, E> for Visitor<E> { } } -impl<'ctx, E: Effect<'ctx>> Tag<'ctx, TagDyn, E> for Visitor<E> { +impl<'ctx, E: Effect> Tag<'ctx, TagDyn, E> for Visitor<E> { fn visit<'a>( &'a mut self, kind: TagDyn, walker: DynWalker<'a, 'ctx, E>, - ) -> Future<'a, 'ctx, Status, E> { + ) -> Future<'a, Status, E> { E::wrap(async move { match kind.0 { crate::TAG_TYPE_NAME => { @@ -81,7 +83,7 @@ impl<'ctx, E: Effect<'ctx>> Tag<'ctx, TagDyn, E> for Visitor<E> { println!("type name:"); self.0 += 1; - walker.walk(self).await; + let _ = walker.walk(self).await; self.0 -= 1; Status::r#continue() @@ -91,7 +93,7 @@ impl<'ctx, E: Effect<'ctx>> Tag<'ctx, TagDyn, E> for Visitor<E> { println!("key:"); self.0 += 1; - walker.walk(self).await; + let _ = walker.walk(self).await; self.0 -= 1; Status::r#continue() @@ -101,7 +103,7 @@ impl<'ctx, E: Effect<'ctx>> Tag<'ctx, TagDyn, E> for Visitor<E> { println!("value:"); self.0 += 1; - walker.walk(self).await; + let _ = walker.walk(self).await; self.0 -= 1; Status::r#continue() @@ -112,63 +114,71 @@ impl<'ctx, E: Effect<'ctx>> Tag<'ctx, TagDyn, E> for Visitor<E> { } } -impl<'ctx, E: Effect<'ctx>> Value<'ctx, DynOwnedStatic<&'static str>, E> for Visitor<E> { +impl<'ctx, E: Effect> Value<'ctx, DynOwnedStatic<&'static str>, E> for Visitor<E> { fn visit<'a>( &'a mut self, OwnedStatic(value): OwnedStatic<&'static str>, - ) -> Future<'a, 'ctx, Flow, E> { + ) -> Future<'a, Flow, E> + where + 'ctx: 'a + { self.tab(); println!("{:?}", value); E::ready(Flow::Continue) } } -impl<'ctx, E: Effect<'ctx>> Value<'ctx, DynOwnedStatic<usize>, E> for Visitor<E> { +impl<'ctx, E: Effect> Value<'ctx, DynOwnedStatic<usize>, E> for Visitor<E> { fn visit<'a>( &'a mut self, OwnedStatic(value): OwnedStatic<usize>, - ) -> Future<'a, 'ctx, Flow, E> { + ) -> Future<'a, Flow, E> + where + 'ctx: 'a { self.tab(); println!("{}", value); E::ready(Flow::Continue) } } -impl<'ctx, E: Effect<'ctx>> Value<'ctx, DynOwnedStatic<bool>, E> for Visitor<E> { - fn visit<'a>(&'a mut self, OwnedStatic(value): OwnedStatic<bool>) -> Future<'a, 'ctx, Flow, E> { +impl<'ctx, E: Effect> Value<'ctx, DynOwnedStatic<bool>, E> for Visitor<E> { + fn visit<'a>(&'a mut self, OwnedStatic(value): OwnedStatic<bool>) -> Future<'a, Flow, E> + where 'ctx: 'a{ self.tab(); println!("{}", value); E::ready(Flow::Continue) } } -impl<'ctx, E: Effect<'ctx>> Value<'ctx, DynOwnedStatic<&'static [&'static str]>, E> for Visitor<E> { +impl<'ctx, E: Effect> Value<'ctx, DynOwnedStatic<&'static [&'static str]>, E> for Visitor<E> { fn visit<'a>( &'a mut self, OwnedStatic(value): OwnedStatic<&'static [&'static str]>, - ) -> Future<'a, 'ctx, Flow, E> { + ) -> Future<'a, Flow, E> + where 'ctx: 'a{ self.tab(); println!("{:?}", value); E::ready(Flow::Continue) } } -impl<'ctx, E: Effect<'ctx>> Value<'ctx, DynOwnedStatic<TypeId>, E> for Visitor<E> { +impl<'ctx, E: Effect> Value<'ctx, DynOwnedStatic<TypeId>, E> for Visitor<E> { fn visit<'a>( &'a mut self, OwnedStatic(value): OwnedStatic<TypeId>, - ) -> Future<'a, 'ctx, Flow, E> { + ) -> Future<'a, Flow, E> + where 'ctx: 'a{ self.tab(); println!("Visit type ID: {:?}", value); E::ready(Flow::Continue) } } -impl<'ctx, E: Effect<'ctx>> Sequence<'ctx, E> for Visitor<E> { +impl<'ctx, E: Effect> Sequence<'ctx, E> for Visitor<E> { fn visit<'a>( &'a mut self, scope: protocol::visitor::sequence::DynSequenceScope<'a, 'ctx, E>, - ) -> Future<'a, 'ctx, Flow, E> { + ) -> Future<'a, Flow, E> { E::wrap(async { self.tab(); println!("sequence{:?}", scope.size_hint().await); |