diff --git a/src/rstd.rs b/src/rstd.rs index 1d706d4..f6f04c6 100644 --- a/src/rstd.rs +++ b/src/rstd.rs @@ -3,6 +3,7 @@ pub mod atomic; pub mod cast; pub mod collections; +mod external_points; pub mod inject; pub mod inlining; mod local_origin; diff --git a/src/rstd/collections/stack.rs b/src/rstd/collections/stack.rs index 83c0d02..b8a62be 100644 --- a/src/rstd/collections/stack.rs +++ b/src/rstd/collections/stack.rs @@ -2,6 +2,7 @@ use crate::func::{context::*, controlflow::ControlFlow}; use crate::rcore::*; +use crate::rstd::external_points::*; use crate::rstd::{inlining::*, nullable::*, point::*, *}; /// Node containing a (nullable) reference to the next node and an element. @@ -35,10 +36,6 @@ impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx>> Serializable for StackNo } } -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>> { @@ -52,21 +49,17 @@ impl< { } -pub trait ExternalPointsProxy<'a, Ctx: Context<'a>, T>: FactoryProxy<'a, Ctx> -where - Self::F: Factory<'a, Ctx>, -{ - fn exp_points_typed(stack: &T, points: &mut impl PointsVisitor<'a, Ctx>); -} - impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>> for A where as WithParseMode>::WithMode: ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, A>, F = Fctr<'a, Ctx, A>>, { - fn ex_points_typed(stack: &Stack<'a, Ctx, Self>, points: &mut impl PointsVisitor<'a, Ctx>) { - < as WithParseMode>::WithMode as ExternalPointsProxy<'a, Ctx, _>>::exp_points_typed(stack, points) + fn ex_points_typed( + mentionable: &Stack<'a, Ctx, Self>, + points: &mut impl PointsVisitor<'a, Ctx>, + ) { + < as WithParseMode>::WithMode as ExternalPointsProxy<'a, Ctx, _>>::exp_points_typed(mentionable, points) } } @@ -76,10 +69,10 @@ where F::Mtbl: MentionableTop<'a, Ctx>, { fn exp_points_typed( - stack: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>, + mentionable: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>, points: &mut impl PointsVisitor<'a, Ctx>, ) { - stack.points_typed(points) + mentionable.points_typed(points) } } @@ -89,10 +82,10 @@ where F::Mtbl: MentionableTop<'a, Ctx>, { fn exp_points_typed( - stack: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>, + mentionable: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>, points: &mut impl PointsVisitor<'a, Ctx>, ) { - stack.points_typed(points) + mentionable.points_typed(points) } } diff --git a/src/rstd/external_points.rs b/src/rstd/external_points.rs new file mode 100644 index 0000000..23384d9 --- /dev/null +++ b/src/rstd/external_points.rs @@ -0,0 +1,12 @@ +use crate::rcore::*; + +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 ExternalPointsProxy<'a, Ctx: Context<'a>, T>: FactoryProxy<'a, Ctx> +where + Self::F: Factory<'a, Ctx>, +{ + fn exp_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>); +}