Diffstat (limited to 'src/walk/walkers/core/struct.rs')
-rw-r--r--src/walk/walkers/core/struct.rs178
1 files changed, 105 insertions, 73 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs
index 393450f..45fba0e 100644
--- a/src/walk/walkers/core/struct.rs
+++ b/src/walk/walkers/core/struct.rs
@@ -1,7 +1,7 @@
use core::{any::TypeId, marker::PhantomData};
use crate::{
- any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt},
+ any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt, StaticType},
any_trait,
effect::{Effect, EffectExt as _, Effective, EffectiveExt, ErasedEffective, ReadyExt as _},
hkt::Marker,
@@ -21,10 +21,6 @@ use crate::{
use super::{noop::NoopWalker, tag::StaticSliceWalker, value::ValueWalker};
-pub enum StaticType {}
-pub enum NamedType {}
-pub enum LifetimeType {}
-
/// Walker for a borrow of a struct.
///
/// This walker implements the struct flow. The struct cannot contain lifetimes.
@@ -52,7 +48,7 @@ pub trait StructTypeInfo<'ctx, M>: 'static {
const FIELDS: &'static [&'static str];
/// The walking errors for the fields.
- type FieldError: Send + Sync;
+ type FieldError: Send + Sync + core::fmt::Debug;
type S: 'static;
@@ -192,11 +188,14 @@ where
Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: <RecoverableProto<E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this, 'visitor, 'hint, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, RecoverableProto<E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
todo!()
// E::map(
// visit_recoverable::<E>(visitor, self),
@@ -223,11 +222,14 @@ where
I: StructTypeInfo<'ctx, M, S = S>,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: MetaHint<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this, 'visitor, 'hint, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E, _>(
@@ -268,11 +270,14 @@ where
I: StructTypeInfo<'ctx, M, S = S>,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: <TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this, 'visitor, 'hint, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_TYPE_NAME.to_int() }>, E, _>(
@@ -313,11 +318,14 @@ where
I: StructTypeInfo<'ctx, M, S = S>,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: <TagProto<TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this, 'visitor, 'hint, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_MAP.to_int() }>, E, _>(TagConst, visitor, NoopWalker::new()),
@@ -354,27 +362,35 @@ where
I: StructTypeInfo<'ctx, M, S = S>,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: <TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
- todo!()
- // E::map(
- // visit_tag::<TagConst<{ TAG_STRUCT.to_int() }>, E, _>(
- // TagConst,
- // visitor,
- // NoopWalker::new(),
- // ),
- // |status| match status {
- // Err(err) => {
- // self.error = Some(StructWalkErrorKind::Tag(err));
- // Flow::Err
- // }
- // Ok(VisitResult::Skipped(_)) => Flow::Continue,
- // Ok(VisitResult::Control(flow)) => flow,
- // },
- // )
+ fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
+ E::as_ctx(
+ (self, visitor),
+ #[inline(always)]
+ |(this, visitor)| {
+ visit_tag::<TagConst<{ TAG_STRUCT.to_int() }>, E, _>(
+ TagConst,
+ visitor.cast(),
+ NoopWalker::new(),
+ )
+ .map(|status| match status {
+ Err(err) => {
+ this.error = Some(StructWalkErrorKind::Tag(err));
+ Flow::Err
+ }
+ Ok(VisitResult::Skipped(_)) => Flow::Continue,
+ Ok(VisitResult::Control(flow)) => flow,
+ })
+ .cast()
+ },
+ )
+ .remove_ctx()
}
#[inline(always)]
@@ -400,11 +416,14 @@ where
I::T: 'static,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: <TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this, 'visitor, 'hint, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
todo!()
// E::map(
// visit_tag::<TagConst<{ TAG_TYPE_ID.to_int() }>, E, _>(
@@ -445,11 +464,14 @@ where
I::T: 'static,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- hint: <TagProto<TagDyn, E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, TagProto<TagDyn, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
match hint.kind.0 {
crate::TAG_TYPE_ID => {
Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>::hint(
@@ -509,11 +531,14 @@ where
I::T: 'static,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: (),
- ) -> ErasedEffective<'a, Flow, E> {
+ fn hint<'this, 'visitor, 'hint, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
todo!()
// E::map(
// visit_value::<_, E>(visitor, BorrowedStatic(self.value)),
@@ -533,22 +558,29 @@ where
}
}
-impl<'ctx, I, S, M, E> Hint<'ctx, SequenceProto<E>> for StructWalker<'ctx, I, S, M, E>
+impl<'ctx, I, S, M: 'ctx, E> Hint<'ctx, SequenceProto<E>> for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
I: StructTypeInfo<'ctx, M, S = S>,
{
#[inline(always)]
- fn hint<'a>(
- &'a mut self,
- visitor: DynVisitor<'a, 'ctx>,
- _hint: <SequenceProto<E> as HintMeta>::Hint,
- ) -> ErasedEffective<'a, Flow, E> {
- todo!()
- // E::map(visit_sequence::<E>(visitor, self), |status| match status {
- // VisitResult::Skipped(_) => Flow::Continue,
- // VisitResult::Control(flow) => flow,
- // })
+ #[inline(always)]
+ fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ &'this mut self,
+ visitor: DynVisitor<'visitor, 'ctx>,
+ hint: MetaHint<'hint, 'ctx, SequenceProto<E>>,
+ ) -> ErasedEffective<'e, Flow, E>
+ where
+ 'ctx: 'this + 'visitor + 'hint + 'e,
+ {
+ E::as_ctx_map((self, visitor), |(this, visitor)| {
+ visit_sequence::<E>(visitor.cast(), *this)
+ .map(|status| match status {
+ VisitResult::Skipped(_) => Flow::Continue,
+ VisitResult::Control(flow) => flow,
+ })
+ .cast()
+ })
}
#[inline(always)]