Point::points_typed
This commit is contained in:
parent
96f697e285
commit
86b87306ef
@ -17,6 +17,7 @@ use crate::func::*;
|
||||
|
||||
pub use self::addresses::*;
|
||||
pub use self::hashing::*;
|
||||
pub use self::points::TakesPoints;
|
||||
pub use self::resolution::*;
|
||||
pub use self::serialization::*;
|
||||
pub use self::slice_deserializer::*;
|
||||
@ -71,7 +72,9 @@ pub trait Mentionable<'a, Ctx: 'a + Context>: 'a + Serializable {
|
||||
}
|
||||
Ctx::hash(&vec)
|
||||
}
|
||||
/// References ([Point]s) to other objects.
|
||||
/// References ([Point]s) to other objects. Typed.
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>);
|
||||
/// References ([Point]s) to other objects. Typeless.
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>);
|
||||
/// [Vec] of [Point]s as used by [`Mentionable::topology`].
|
||||
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
|
||||
pub trait TakesPoints<'a, Ctx: 'a + Context> {
|
||||
fn take<A: Mentionable<'a, Ctx>>(&mut self, point: Point<'a, Ctx, A>);
|
||||
fn take<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>);
|
||||
}
|
||||
|
@ -56,6 +56,12 @@ impl<'a, Ctx: 'a + Context> Mentionable<'a, Ctx> for TypelessMentionable<'a, Ctx
|
||||
self.t_topology
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
for point in self.t_points.iter() {
|
||||
points.take(point)
|
||||
}
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
points.extend(self.t_points.iter().map(Clone::clone));
|
||||
}
|
||||
|
@ -46,6 +46,8 @@ impl<'a, Ctx: 'a + Context, A: Atomic> Mentionable<'a, Ctx> for AtomicObject<A>
|
||||
Ctx::hash(b"")
|
||||
}
|
||||
|
||||
fn points_typed(&self, _points: &mut impl TakesPoints<'a, Ctx>) {}
|
||||
|
||||
fn points(&self, _points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,13 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for RB
|
||||
}
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
match self {
|
||||
RBNode::R(r) => r.points_typed(points),
|
||||
RBNode::B(b) => b.points_typed(points),
|
||||
}
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
match self {
|
||||
RBNode::R(r) => r.points(points),
|
||||
@ -149,6 +156,12 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for BN
|
||||
}
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
self.cl.points_typed(points);
|
||||
self.cr.points_typed(points);
|
||||
self.key.points_typed(points);
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
self.cl.points(points);
|
||||
self.cr.points(points);
|
||||
@ -165,6 +178,12 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for RN
|
||||
}
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
self.cl.points_typed(points);
|
||||
self.cr.points_typed(points);
|
||||
self.key.points_typed(points);
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
self.cl.points(points);
|
||||
self.cr.points(points);
|
||||
|
@ -42,6 +42,11 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx>
|
||||
StackNodeFactory::new(self.element.factory())
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
self.rest.points_typed(points);
|
||||
self.element.points_typed(points);
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
self.rest.points(points);
|
||||
self.element.points(points);
|
||||
|
@ -108,6 +108,12 @@ impl<'a, Ctx: 'a + Context, SP: StaticPair<'a, Ctx>> Mentionable<'a, Ctx> for St
|
||||
}
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
let (a, b) = self.pair.elements();
|
||||
a.points_typed(points);
|
||||
b.points_typed(points);
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
let (a, b) = self.pair.elements();
|
||||
a.points(points);
|
||||
|
@ -41,6 +41,13 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Nu
|
||||
}
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
match self {
|
||||
Nullable::Null(_) => {}
|
||||
Nullable::NotNull(point) => points.take(point),
|
||||
}
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
match self {
|
||||
Nullable::Null(_) => {}
|
||||
|
@ -23,6 +23,10 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Mentionable<'a, Ctx> for Po
|
||||
Ctx::hash(&self.point)
|
||||
}
|
||||
|
||||
fn points_typed(&self, points: &mut impl TakesPoints<'a, Ctx>) {
|
||||
points.take(self)
|
||||
}
|
||||
|
||||
fn points(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>) {
|
||||
points.push(self.typeless());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user