Diffstat (limited to 'src/walk/walkers/core/struct.rs')
-rw-r--r--src/walk/walkers/core/struct.rs51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs
index d98043d..e6138fb 100644
--- a/src/walk/walkers/core/struct.rs
+++ b/src/walk/walkers/core/struct.rs
@@ -16,7 +16,7 @@ use crate::{
walker::hint::{Hint, HintMeta, HintProto, MetaHint, MetaKnown},
DynVisitor, DynWalker,
},
- DynWalkerAdapter, Flow, Status, WalkerTypes, TAG_FIELD_NAMES, TAG_MAP, TAG_STRUCT, TAG_TYPE_ID,
+ DynWalkerAdapter, Flow, Status, TAG_FIELD_NAMES, TAG_MAP, TAG_STRUCT, TAG_TYPE_ID,
TAG_TYPE_NAME,
};
@@ -25,7 +25,7 @@ use super::{noop::NoopWalker, value::ValueWalker};
/// Walker for a borrow of a struct.
///
/// This walker implements the struct flow. The struct cannot contain lifetimes.
-pub struct StructWalker<'ctx, I: StructTypeInfo<'ctx, M, S = S>, S, M, E> {
+pub struct StructWalker<'ctx, I: StructTypeInfo<'ctx, M, E, S = S>, S, M, E: Effect> {
/// Struct value to walk.
value: &'ctx I::T,
@@ -41,7 +41,7 @@ pub struct StructWalker<'ctx, I: StructTypeInfo<'ctx, M, S = S>, S, M, E> {
}
/// Type info about a struct needed by [`StructWalker`].
-pub trait StructTypeInfo<'ctx, M>: 'static {
+pub trait StructTypeInfo<'ctx, M, E: Effect>: 'static {
/// Name of the struct.
const NAME: &'static str;
@@ -57,7 +57,7 @@ pub trait StructTypeInfo<'ctx, M>: 'static {
type T: Send + Sync;
/// Walk the given field.
- fn walk_field<'a, E: Effect>(
+ fn walk_field<'a>(
index: usize,
value: &'ctx Self::T,
visitor: DynVisitor<'a, 'ctx>,
@@ -88,9 +88,9 @@ pub struct StructWalkError<T> {
kind: StructWalkErrorKind<T>,
}
-impl<'ctx, I, S, M, E> StructWalker<'ctx, I, S, M, E>
+impl<'ctx, I, S, M, E: Effect> StructWalker<'ctx, I, S, M, E>
where
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
/// Create walker from a borrow of a struct.
pub fn new(value: &'ctx I::T) -> Self {
@@ -113,20 +113,15 @@ where
}
}
-impl<'ctx, I, S, M, E> WalkerTypes for StructWalker<'ctx, I, S, M, E>
-where
- I: StructTypeInfo<'ctx, M, S = S>,
-{
- type Error = StructWalkError<I::FieldError>;
- type Output = ();
-}
-
impl<'ctx, I, S, E, M> crate::Walker<'ctx, E> for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
{
+ type Error = StructWalkError<I::FieldError>;
+ type Output = ();
+
#[inline(always)]
fn walk<'b: 'c, 'c>(
self,
@@ -177,7 +172,7 @@ any_trait! {
HintProto<TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
] where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = StaticType>,
+ I: StructTypeInfo<'ctx, M, E, S = StaticType>,
M: 'ctx,
I::T: 'static
}
@@ -185,7 +180,7 @@ any_trait! {
impl<'ctx, I, S, M, E> Hint<'ctx, RecoverableProto<E>> for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
{
#[inline(always)]
@@ -220,7 +215,7 @@ impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }
for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
fn hint<'this, 'visitor, 'hint, 'e>(
@@ -268,7 +263,7 @@ impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>,
for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
fn hint<'this, 'visitor, 'hint, 'e>(
@@ -316,7 +311,7 @@ impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>
for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
fn hint<'this, 'visitor, 'hint, 'e>(
@@ -360,7 +355,7 @@ impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>
for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
@@ -403,7 +398,7 @@ impl<'ctx, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>
for StructWalker<'ctx, I, StaticType, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = StaticType>,
+ I: StructTypeInfo<'ctx, M, E, S = StaticType>,
I::T: 'static,
{
#[inline(always)]
@@ -451,7 +446,7 @@ where
impl<'ctx, I, M, E> Hint<'ctx, TagProto<TagDyn, E>> for StructWalker<'ctx, I, StaticType, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = StaticType>,
+ I: StructTypeInfo<'ctx, M, E, S = StaticType>,
I::T: 'static,
{
#[inline(always)]
@@ -519,7 +514,7 @@ impl<'ctx, I, M, E> Hint<'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>>
for StructWalker<'ctx, I, StaticType, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = StaticType>,
+ I: StructTypeInfo<'ctx, M, E, S = StaticType>,
I::T: 'static,
{
#[inline(always)]
@@ -553,7 +548,7 @@ where
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>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
@@ -592,7 +587,7 @@ where
impl<'ctx, I, S, M: 'ctx, E> SequenceScope<'ctx, E> for StructWalker<'ctx, I, S, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = S>,
+ I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
fn size_hint(&mut self) -> ErasedEffective<'_, (usize, Option<usize>), E> {
@@ -613,7 +608,7 @@ where
let index = self.index;
self.index += 1;
- I::walk_field::<E>(index, self.value, visitor).map(|result| match result {
+ I::walk_field(index, self.value, visitor).map(|result| match result {
Ok(flow) => flow,
Err(err) => {
// Record the error and signal a break.
@@ -639,7 +634,7 @@ where
impl<'ctx, I, M: 'ctx, E> RecoverableScope<'ctx, E> for StructWalker<'ctx, I, StaticType, M, E>
where
E: Effect,
- I: StructTypeInfo<'ctx, M, S = StaticType>,
+ I: StructTypeInfo<'ctx, M, E, S = StaticType>,
I::T: 'static,
{
#[inline(always)]