From 0fa540f7aa12729ebc1cbb1983b21361ac7c9f85 Mon Sep 17 00:00:00 2001 From: timofey Date: Sat, 29 Jul 2023 09:55:31 +0000 Subject: [PATCH] `ExternalPoints` --- src/rstd/collections/stack.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/rstd/collections/stack.rs b/src/rstd/collections/stack.rs index 5169828..00e1c51 100644 --- a/src/rstd/collections/stack.rs +++ b/src/rstd/collections/stack.rs @@ -35,8 +35,21 @@ impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx>> Serializable for StackNo } } -pub trait StackCompatible<'a, Ctx: Context<'a>>: Mentionable<'a, Ctx> { - fn points_typed_rest(stack: &Stack<'a, Ctx, Self>, points: &mut impl PointsVisitor<'a, Ctx>); +pub trait ExternalPoints<'a, Ctx: Context<'a>, T: MentionableBase<'a, Ctx>> { + fn ex_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>); +} + +pub trait StackCompatible<'a, Ctx: Context<'a>>: + Mentionable<'a, Ctx> + ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>> +{ +} + +impl< + 'a, + Ctx: Context<'a>, + A: Mentionable<'a, Ctx> + ExternalPoints<'a, Ctx, Stack<'a, Ctx, A>>, + > StackCompatible<'a, Ctx> for A +{ } pub trait StackCompatibleProxy<'a, Ctx: Context<'a>>: FactoryProxy<'a, Ctx> @@ -48,12 +61,13 @@ where fn points_typed_rest(stack: &Self::T, points: &mut impl PointsVisitor<'a, Ctx>); } -impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> StackCompatible<'a, Ctx> for A +impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>> + for A where as WithParseMode>::WithMode: StackCompatibleProxy<'a, Ctx, T = Stack<'a, Ctx, A>, F = Fctr<'a, Ctx, A>>, { - fn points_typed_rest(stack: &Stack<'a, Ctx, Self>, points: &mut impl PointsVisitor<'a, Ctx>) { + fn ex_points_typed(stack: &Stack<'a, Ctx, Self>, points: &mut impl PointsVisitor<'a, Ctx>) { < as WithParseMode>::WithMode as StackCompatibleProxy<'a, Ctx>>::points_typed_rest(stack, points) } } @@ -102,7 +116,7 @@ impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx>> MentionableTop<'a, Ctx> for StackNode<'a, Ctx, A> { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) { - >::points_typed_rest(&self.rest, points); + >::ex_points_typed(&self.rest, points); self.element.points_typed(points); } }