30 lines
1.0 KiB
Rust
30 lines
1.0 KiB
Rust
use super::*;
|
|
|
|
/// Topological [Mentionable]. Allows iterating over [Point]s it references, if any;
|
|
pub trait MentionableTop<'a, Ctx: Context<'a>>: 'a {
|
|
/// See implementation for the definition.
|
|
/// Hash of all the references' points concatenated, ordered, non-unique.
|
|
/// Used for walking over object trees to ensure two objects with different references don't collide.
|
|
fn topology_hash(&self) -> Hash
|
|
where
|
|
Self: Mentionable<'a, Ctx>,
|
|
{
|
|
let mut vec = Vec::new();
|
|
self.points_typed(&mut vec);
|
|
Ctx::hash(&vec)
|
|
}
|
|
|
|
/// References ([Point]s) to other objects. Typed.
|
|
fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>)
|
|
where
|
|
Self: Mentionable<'a, Ctx>;
|
|
}
|
|
|
|
pub type TopoVec<'a, Ctx> = Vec<Arc<dyn SingularResolution<'a, Ctx>>>;
|
|
|
|
impl<'a, Ctx: Context<'a>> PointsVisitor<'a, Ctx> for TopoVec<'a, Ctx> {
|
|
fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) {
|
|
self.push(Arc::new(point.clone()) as _);
|
|
}
|
|
}
|