TakesPoints -> PointsVisitor

This commit is contained in:
AF 2023-07-01 14:45:01 +00:00
parent ffd0cf6ec2
commit 4425b4c545
10 changed files with 21 additions and 21 deletions

View File

@ -33,7 +33,7 @@ pub use self::inctx::InCtx;
pub use self::inlining::{Inlining, InliningExt, InliningResultExt}; pub use self::inlining::{Inlining, InliningExt, InliningResultExt};
pub use self::origin::{OFctr, Origin}; pub use self::origin::{OFctr, Origin};
pub use self::point::Point; pub use self::point::Point;
pub use self::points::TakesPoints; pub use self::points::PointsVisitor;
pub use self::resolution::{ pub use self::resolution::{
Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError, Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError,
ResolutionFailure, ResolutionResult, Resolver, ResolverMap, ResolutionFailure, ResolutionResult, Resolver, ResolverMap,
@ -60,7 +60,7 @@ pub trait Mentionable<'a, Ctx: Context<'a>>: 'a + Serializable {
Ctx::hash(&vec) Ctx::hash(&vec)
} }
/// References ([Point]s) to other objects. Typed. /// References ([Point]s) to other objects. Typed.
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>); fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>);
} }
/// [`Factory`] associated with the [`Mentionable`]. Mostly useful for `type` definitions. /// [`Factory`] associated with the [`Mentionable`]. Mostly useful for `type` definitions.

View File

@ -1,14 +1,14 @@
use super::*; use super::*;
/// Visitor used in [`Mentionable::points_typed`]. /// Visitor used in [`Mentionable::points_typed`].
pub trait TakesPoints<'a, Ctx: Context<'a>> { pub trait PointsVisitor<'a, Ctx: Context<'a>> {
/// Visit a [Point]. /// Visit a [Point].
fn take<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>); fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>);
} }
impl<'a, Ctx: Context<'a>> TakesPoints<'a, Ctx> for Vec<u8> { impl<'a, Ctx: Context<'a>> PointsVisitor<'a, Ctx> for Vec<u8> {
/// The only natural implementation, as used in [`Mentionable::topology`]. /// The only natural implementation, as used in [`Mentionable::topology`].
fn take<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) { fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) {
self.extend(point.point) self.extend(point.point)
} }
} }

View File

@ -47,7 +47,7 @@ impl<'a, Ctx: Context<'a>, A: Atomic> Mentionable<'a, Ctx> for AtomicObject<A> {
Ctx::hash(b"") Ctx::hash(b"")
} }
fn points_typed(&self, _points: &mut impl TakesPoints<'a, Ctx>) {} fn points_typed(&self, _points: &mut impl PointsVisitor<'a, Ctx>) {}
} }
/// Generic implementation of a [Factory] for [Atomic]s. /// Generic implementation of a [Factory] for [Atomic]s.

View File

@ -42,7 +42,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Sta
StackNodeFactory::new(self.element.factory()) StackNodeFactory::new(self.element.factory())
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
self.rest.points_typed(points); self.rest.points_typed(points);
self.element.points_typed(points); self.element.points_typed(points);
} }

View File

@ -112,7 +112,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Nod
NodeFactory(self.key.factory()) NodeFactory(self.key.factory())
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
self.l.points_typed(points); self.l.points_typed(points);
self.r.points_typed(points); self.r.points_typed(points);
self.key.points_typed(points); self.key.points_typed(points);
@ -126,7 +126,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Tre
TreeFactory(self.node.factory()) TreeFactory(self.node.factory())
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
self.node.points_typed(points); self.node.points_typed(points);
} }
} }

View File

@ -109,7 +109,7 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> Mentionable<'a, Ctx> for Sta
} }
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
let (a, b) = self.pair.elements(); let (a, b) = self.pair.elements();
a.points_typed(points); a.points_typed(points);
b.points_typed(points); b.points_typed(points);

View File

@ -42,10 +42,10 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Nul
} }
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
match self { match self {
Self::Null(_) => {} Self::Null(_) => {}
Self::NotNull(point) => points.take(point), Self::NotNull(point) => points.visit(point),
} }
} }
} }

View File

@ -23,8 +23,8 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Poi
Ctx::hash(&self.point) Ctx::hash(&self.point)
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
points.take(self) points.visit(self)
} }
} }

View File

@ -52,8 +52,8 @@ impl<'a, Ctx: Context<'a>> Resolver<'a, Ctx> for SingularResolver<'a, Ctx> {
} }
} }
impl<'a, Ctx: Context<'a>> TakesPoints<'a, Ctx> for Vec<Rc<dyn SingularResolution<'a, Ctx>>> { impl<'a, Ctx: Context<'a>> PointsVisitor<'a, Ctx> for Vec<Rc<dyn SingularResolution<'a, Ctx>>> {
fn take<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) { fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) {
self.push(Rc::new(point.clone()) as Rc<dyn SingularResolution<'a, Ctx>>); self.push(Rc::new(point.clone()) as Rc<dyn SingularResolution<'a, Ctx>>);
} }
} }

View File

@ -59,9 +59,9 @@ impl<'a, Ctx: Context<'a>> Mentionable<'a, Ctx> for TypelessMentionable<'a, Ctx>
self.t_topology self.t_topology
} }
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) { fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>) {
for point in self.t_points.iter() { for point in self.t_points.iter() {
points.take(point) points.visit(point)
} }
} }
} }
@ -220,12 +220,12 @@ where
} }
} }
impl<'a, Ctx: Context<'a>> TakesPoints<'a, Ctx> impl<'a, Ctx: Context<'a>> PointsVisitor<'a, Ctx>
for Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>> for Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>
where where
Ctx::LookupError: From<CastError<'a>>, Ctx::LookupError: From<CastError<'a>>,
{ {
fn take<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) { fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) {
self.push(point.typeless()); self.push(point.typeless());
} }
} }